We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Determine and replacing selected text in a text cell

Thread ID:





68938 Oct 5,2007 04:37 PM UTC Oct 5,2007 06:13 PM UTC WinForms 1
Tags: GridControl
Kamen Yotov
Asked On October 5, 2007 04:37 PM UTC

I need to implement the following:

1) Handle right-click on a text grid cell
2) Determine where on the text the click was
3) Change the selection to the word which was clicked (for my definition of word)
4) Get the string representing the word
5) DoSomething(Word)
6) Replace the original word with the result of (5) above

Looking at the grid interface I could not do most of the above. Can you please tell me if this is possible?

haneefm [Syncfusion]
Replied On October 5, 2007 06:13 PM UTC

Hi Kamen,

This can be achived by handling the CurrentCellControlGotFocus event of the Grid and subscribe the GridTextBoxControl.MouseDown event to detect the right mousebutton. In the MouseDown eventhandler, you can use the TextBox.SelectionLength/TextBox.SelectedText property of the GridTextBoxControl to replace the selected text. Below are the codes:

private void gridControl1_CurrentCellControlGotFocus(object sender, System.Windows.Forms.ControlEventArgs e)
GridTextBoxControl GridTextBox = e.Control as GridTextBoxControl;
GridTextBox.MouseDown +=new MouseEventHandler(GridTextBox_MouseDown);
private void GridTextBox_MouseDown(object sender, MouseEventArgs e)
if( e.Button == MouseButtons.Right )
GridTextBoxControl GridTextBox = sender as GridTextBoxControl;
if( GridTextBox.SelectionLength > 0)
GridTextBox.SelectedText = "RightProcess";

Please refer to the attached sample for implementation and let me know if this helps.

Best regards,


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon