查看積分策略說明發表回覆
Discuz! 代碼
提示插入
直接插入
說明訊息

插入粗體文本 插入斜體文本 插入下劃線 置中對齊 插入超級連結 插入信件位址 插入圖像 插入 flash 插入代碼 插入引言 插入列表
刪除線 直線分隔線 虛線分隔線
    
添加文字底框
內容 [字數檢查]:

表情符號

更多 Smilies
字型大小 |||
溫馨提示:本區開放遊客瀏覽。


文章關鍵字 : [功能說明]
(關鍵字可加強搜索準確性, 如關鍵字多於一組, 請以 , 作分隔, e.g. : 阿笨,shiuh,第一笨)

 關閉 URL 識別 | html 禁用
 關閉 表情符號 | 表情符號 可用
 關閉 Discuz! 代碼 | Discuz! 代碼 可用
使用個人簽名
接收新回覆信件通知
推薦放檔網絡空間

檔案(Torent, zip等)
  1. freedl
  2. multiupload
  3. btghost
  4. 便當狗
  5. mediafire
  6. pillowangel
圖片(JPG, GIF等)
  1. hotimg
  2. tinypic
  3. mousems2
  4. imageshack
  5. imm.io
>>>歡迎推薦好用空間


最新10篇文章回顧
evildog

 發表於 2013-8-1 03:25 PM

新增datagridview的KeyDown事件,判斷如果按下Enter就設定CurrentCell為下一個儲存格。
因為我對VB.NET不熟只懂C#,下面提供老外的C#解答:

private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
       if (e.KeyCode == Keys.Enter)      // 如果按下Enter
       {               
              e.SuppressKeyPress=true;    // 停止DataGridView對Enter預設的反應
              int iColumn = dataGridView1.CurrentCell.ColumnIndex;    // 目前儲存格的行號
              int iRow = dataGridView1.CurrentCell.RowIndex;       // 目前儲存格的列號
              
              // 判斷有沒有下一個儲存格,如果沒有就跳到下一列的第一行,否則就跳到下一個儲存格
              if (iColumn == dataGridView1.Columns.Count-1)
                    dataGridView1.CurrentCell = dataGridView1[0, iRow + 1];
              else
                    dataGridView1.CurrentCell = dataGridView1[iColumn + 1, iRow];
        }
}

[evildog 在  2013-8-1 03:28 PM 作了最後編輯]


htkstw

 發表於 2013-7-31 06:54 PM

請問,在DataGridView中,編輯儲存格後,按Enter鍵如何讓它不要跳到下一列,而是跳到下一個儲存格?

謝謝





所在時區為 GMT+8, 現在時間是 2024-4-26 10:27 PM
清除 Cookies - 連絡我們 - TWed2k © 2001-2046 - 純文字版 - 說明
Discuz! 0.1 | Processed in 0.017311 second(s), 6 queries , Qzip disabled