You need to get the DataGridTextBoxColumn.TextBox member, and retrieve the SelectedText from it for the active cell. The sample shows how you can do this as part of handling this TextBox’s rightClick. This code assumes you have specifically added DataGridTextBoxColumn for each column style. You can also download a VB sample.
private void HandleMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Right)
{
DataGridTableStyle ts = dataGrid1.TableStyles[''customers''];
DataGridTextBoxColumn cs = (DataGridTextBoxColumn)ts.GridColumnStyles[dataGrid1.CurrentCell.ColumnNumber];
MessageBox.Show(''Selected: '' + cs.TextBox.SelectedText);
}
}
Share with