At run time the grid cell's focus is usually determined by the user's mouse and keyboard interaction with the grid. However, if you choose to, you can set the column and row of the grid that has focus using the Col and Row properties of the grid.
In this topic you'll add two NumbericUpDown controls to the form. When the value in those boxes changes, the column and row focus of the grid will change.
Complete the following steps:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.C1TrueDBGrid1.Col = Me.NumericUpDown1.Value |
To write code in C#
C# |
Copy Code
|
---|---|
this.c1TrueDBGrid1.Col = this.numericUpDown1.Value; |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.C1TrueDBGrid1.Row = Me.NumericUpDown2.Value |
To write code in C#
C# |
Copy Code
|
---|---|
this.c1TrueDBGrid1.Row = this.numericUpDown2.Value; |
Change the value in the NumericUpDown boxes. Note that the focus of the grid changes and the grid scrolls to bring the column and row in focus into view: