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.
Unfortunately, activation email could not send to your email. Please try again.

Determine and replacing selected text in a text cell

Thread ID:

Created:

Updated:

Platform:

Replies:

68938 Oct 5,2007 12:37 PM Oct 5,2007 02:13 PM Windows Forms 1
loading
Tags: GridControl
Kamen Yotov
Asked On October 5, 2007 12:37 PM

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 02:13 PM

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.
ReplaceSelectText.zip

Best regards,
Haneef

CONFIRMATION

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.

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.

;