How to move the cursor position to the end of the text in WinForms GridGroupingControl?
Move the cursor position
To set the
record with the cursor at the end position while moving the cursor dynamically,
you can use the CurrentCell.MoveTo method. After moving the
CurrentCell to a particular cell, you can set the cursor at the end position by
using CurrentCell.Renderer.
If you want to highlight the cell value in a cell, you can use renderer.TextBox.SelectAll method instead of using renderer.TextBox.SelectionStart.
C#
private void moveBtn_Click(object sender, EventArgs e)
{
//Set your needed column index
int colIndex = this.gridGroupingControl1.TableDescriptor.FieldToColIndex(0);
//Getting the record rowIndex based on its position
int rowIndex = this.gridGroupingControl1.Table.Records[0].GetRowIndex();
//Moving the current cell
this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(rowIndex, colIndex, Syncfusion.Windows.Forms.Grid.GridSetCurrentCellOptions.SetFocus);
this.gridGroupingControl1.Focus();
//Setting the cursor at end position of cell
if (this.gridGroupingControl1.TableControl.CurrentCell.Renderer is GridTextBoxCellRenderer)
{
GridTextBoxCellRenderer renderer = this.gridGroupingControl1.TableControl.CurrentCell.Renderer as GridTextBoxCellRenderer;
renderer.TextBox.SelectionStart = renderer.TextBox.Text.Length;
}
} VB
Private Sub moveBtn_Click(ByVal sender As Object, ByVal e As EventArgs)
'Set your needed column index
Dim colIndex As Integer = Me.gridGroupingControl1.TableDescriptor.FieldToColIndex(0)
'Getting the record rowIndex based on its position
Dim rowIndex As Integer = Me.gridGroupingControl1.Table.Records(0).GetRowIndex()
'Moving the current cell
Me.gridGroupingControl1.TableControl.CurrentCell.MoveTo(rowIndex, colIndex, Syncfusion.Windows.Forms.Grid.GridSetCurrentCellOptions.SetFocus)
Me.gridGroupingControl1.Focus()
'Setting the cursor at end position of cell
If TypeOf Me.gridGroupingControl1.TableControl.CurrentCell.Renderer Is GridTextBoxCellRenderer Then
Dim renderer As GridTextBoxCellRenderer = TryCast(Me.gridGroupingControl1.TableControl.CurrentCell.Renderer, GridTextBoxCellRenderer)
renderer.TextBox.SelectionStart = renderer.TextBox.Text.Length
End If
End SubNote:
In the sample below, we have provided the two buttons. If you press the Moving with cursor at end button, the current cell will be moved to a particular cell with the cursor at the end position. The current cell will be moved with highlighting the cell value if you press the Moving with Cell Value highlighting button.
The screenshot below illustrates the movement of the cursor position in the GridGroupingControl.


Conclusion
I hope you
enjoyed learning how to move the cursor position to the end of
the text in WinForms GridGroupingControl.
You can refer
to our WinForms GridGroupingControl’s feature tour page to
know about its other groundbreaking feature representations. You can also
explore our WinForms GridGroupingControl documentation to
understand how to present and manipulate data.
For current
customers, you can check out our WinForms components from the License and
Downloads page. If you are new to Syncfusion, you can try our
30-day free trial to check out our WinForms
GridGroupingControl and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!