How to get the selected text from a TextBox cell in WinForms GridControl?
In order to get the selected text from a TextBox cell in a WinForms GridControl, the TextBox renderer has to be acquired from the CurrentCell renderer inside the CurrentCellStartEditing event.
// Trigger the required event.
gridControl1.CurrentCellStartEditing += gridControl1_CurrentCellStartEditing;
void gridControl1_CurrentCellStartEditing(object sender, CancelEventArgs e)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
if (cc.Renderer is GridTextBoxCellRenderer)
{
GridTextBoxCellRenderer renderer = cc.Renderer as GridTextBoxCellRenderer;
renderer.TextBox.MouseUp += TextBox_MouseUp;
}
}
void TextBox_MouseUp(object sender, MouseEventArgs e)
{
TextBox text = sender as TextBox;
if (text.SelectionLength > 0)
{
MessageBox.Show(text.SelectedText);
}
}'Trigger the required event.
AddHandler Me.gridControl1.CurrentCellStartEditing, AddressOf gridControl1_CurrentCellStartEditing
Private Sub gridControl1_CurrentCellStartEditing(ByVal sender As Object, ByVal e As CancelEventArgs)
Dim cc As GridCurrentCell = Me.gridControl1.CurrentCell
If TypeOf cc.Renderer Is GridTextBoxCellRenderer Then
Dim renderer As GridTextBoxCellRenderer = TryCast(cc.Renderer, GridTextBoxCellRenderer)
AddHandler renderer.TextBox.MouseUp, AddressOf TextBox_MouseUp
End If
End Sub
Private Sub TextBox_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim text As TextBox = TryCast(sender, TextBox)
If text.SelectionLength > 0 Then
MessageBox.Show(text.SelectedText)
End If
End SubThe
screenshot below displays the selected text from the textbox cell.

Sample Links:
Conclusion
I hope you enjoyed learning about how to get the selected text from a TextBox cell in WinForms GridControl.
You can refer to our WinForms GridControl feature tour page to know about its other groundbreaking feature representations and WinForms GridControl documentation, and how to quickly get started for configuration specifications.
For current customers, you can check out our 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 other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!