快捷键对控件GridControl新增数据

按[Down] 自动增加新行

按[CTRL+Down] DataGridView自动增加最后一行
   
     
1 if (e.Control == true && e.KeyCode == Keys.Down)
2 {
3 if (m_gridView.IsLastRow)
4 {
5 DataRowView CurrRow = m_currentBindingSource.Current as DataRowView;
6 m_gridView.AddNewRow();
7 int row = m_gridView.FocusedRowHandle;
8 foreach (GridColumn col in m_gridView.Columns)
9 {
10 if (m_gridView.GetRowCellValue(row,col.FieldName).ToString() == "" )
11 m_gridView.SetRowCellValue(row, col.FieldName, CurrRow[col.FieldName]);
12 }
13 m_gridView.UpdateCurrentRow();
14 }
15 } else if (e.KeyCode == Keys.Down)
16 { if (m_gridView.IsLastRow && m_gridView.IsEditing)
17 m_gridView.AddNewRow();
18 }
19 }

你可能感兴趣的:(grid)