At run time cell edit mode is usually entered by the user's mouse and keyboard interaction with the grid. However, if you choose, you can set the currently focused cell to enter edit mode in code. To enter edit mode, simply set the EditActive property to True.
In the following steps you'll add two labels and text boxes to your project to choose a cell to edit, a button to change focus to that cell, and another button that enters the focused cell into edit mode.
Complete the following steps:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.C1TrueDBGrid1.Col = Me.TextBox1.Text Me.C1TrueDBGrid1.Row = Me.TextBox2.Text |
To write code in C#
C# |
Copy Code
|
---|---|
this.c1TrueDBGrid1.Col = this.textBox1.Text; this.c1TrueDBGrid1.Row = this.textBox2.Text; |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.C1TrueDBGrid1.EditActive = True |
To write code in C#
C# |
Copy Code
|
---|---|
this.c1TrueDBGrid1.EditActive = true; |
Using the textboxes and buttons, you can change the cell that is in focus, and you can enter edit mode on the selected cell. Complete the following:
The selected cell will enter edit mode: