Using the Row and Col properties you can get the index of the currently selected cell's row and column. In the following example, you'll add two text boxes to your grid application, one that displays the currently selected row and another displaying the current column.
Complete the following steps to display the current row and column:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub C1TrueDBGrid1_RowColChange(ByVal sender As System.Object, ByVal e As C1.Win.C1TrueDBGrid.RowColChangeEventArgs) Handles C1TrueDBGrid1.RowColChange Me.TextBox1.Text = C1TrueDBGrid1.Row Me.TextBox2.Text = C1TrueDBGrid1.Col End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
private void c1TrueDBGrid1_RowColChange(object sender, RowColChangeEventArgs e) { this.textBox1.Text = c1TrueDBGrid1.Row; this.textBox2.Text = c1TrueDBGrid1.Col; } |
This code will set the current row and column indexes to appear in the text boxes.
Run your application and observe that the row and column text boxes display the row and column index for the selected grid cell:
Choose a different cell and note that the text in the text boxes changes to display the currently selected cell's row and column index.