|
如何控制在infoGridView中的一個Cell做更改後,按向下鍵(Down),則讓遊標移到下一個Row的這個欄位,不要跑到第一個column去?(AutoApply設為True) |
|
|
可以在InfoDataSet的BeforeApplyUpdates事件中記下位置,然後在AfterApplyUpdates事件中還原,如下:
Point cellPoint = Point.Empty; // 設定一個Local變數 private void infoDataSet1_BeforeApplyUpdates(object sender, EventArgs e) { if (this.infoDataGridView1.SelectedCells.Count == 1) { DataGridViewCell cell = this.infoDataGridView1.SelectedCells[0]; cellPoint = new Point(cell.ColumnIndex, cell.RowIndex); // 紀錄 } }
private void infoDataSet1_AfterApplyUpdates(object sender, EventArgs e) { if (cellPoint != Point.Empty && this.infoDataGridView1.SelectedCells.Count == 1) { this.infoDataGridView1.SelectedCells[0].Selected = false; this.infoDataGridView1[cellPoint.X, cellPoint.Y].Selected = true; // 還原 cellPoint = Point.Empty; } }
|
|
|