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. Image for the cookie policy date

Cell select all text behavior when user click on it

Hi

When the user click on a cell to edit the text, the default behavior is to select all the text. It's a good default behavior since most of the time users expect to replace the text, but in this specific case the user expect to add text. So we would like to change that behavior so the cursor is position at the end of the text when the user click on the cell to edit it.

Is there a way to do this?

Thanks,

Dominik


2 Replies

DO Dominik.Delisle-Ong October 14, 2010 03:45 PM UTC

Never mind, I found the solution

Just need to hook to gridControl.CurrentCellControlGotFocus, cast the control to GridOriginalTextBoxControl and update the SelectionLength and SelectionStart properties

gridControl.CurrentCellControlGotFocus += new ControlEventHandler(gridBinder_CurrentCellControlGotFocus);

...

private void gridBinder_CurrentCellControlGotFocus(object sender, ControlEventArgs e)
{
GridOriginalTextBoxControl textBoxControl = e.Control as GridOriginalTextBoxControl;
if (textBoxControl == null)
return;

textBoxControl.SelectionLength = 0;
textBoxControl.SelectionStart = textBoxControl.TextLength;
}

Thanks,

Dominik



RC Rajadurai C Syncfusion Team October 14, 2010 08:13 PM UTC

Hi Dominik,

Thanks for your interest in Syncfusion Products.

You could get the SelectAll functionality in gridcell by handling the following property setting alone.

this.gridControl1.ActivateCurrentCellBehavior = GridCellActivateAction.SelectAll;


Please let us know if you have any further concerns.

Regards,
Rajadurai


Loader.
Live Chat Icon For mobile
Up arrow icon