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

Selecting all text in Text cell on entering edit mode

Hello everyone,

I've been trying to figure out how to get the entire cell contents (regular text cell) to be highlighted when the user enters edit mode for the cell.

I've been able to achieve the same functionality by using the EventHandler for CurrentCellMoved as follows (but this only highlights all the text when I double click into the cell, not when I start to edit it by pressing "Tab" or "Enter")

                private void grid_CurrentCellMoved(object sender, GridCurrentCellMovedEventArgs args)
{
grid.Model.CurrencyManager.CurrentCell.BeginEdit(true);
}

Does anyone know what I can do to get the entire cell contents highlighted when it enters edit mode?

Any help is appreciated.

Thank you.

James

3 Replies

GV Ganesan V Syncfusion Team June 9, 2014 11:32 AM UTC

Hi James,

Thank you for using Syncfusion Products.

You can highlight the cell contents when user enter into edit mode by using the ActivateCurrentCellBehavior property. Please refer the following code example :

Code Snippet[C#]:

this.dataGrid.Model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.SelectAll;

Please let us know if you have any queries,

Thanks,

Ganesan

 



JA James June 9, 2014 10:31 PM UTC

Thanks for the code Ganesan, it helps slightly but it's not exactly what I want.

The code you provided selects all the text whenever a cell is activated, I want all the text to be selected only when the cell enters edit mode.

The reason why I ask for this is because I want the user to be able to select an entire row using the mouse without entering the edit mode. With the code you have provided the user can perform "single-click to edit" but I would like it to remain as "double-click to edit" (so that the user can single click to select the record and get right click context menu items).

Please respond.

James


DR Deepak Raj Sundar Syncfusion Team June 11, 2014 01:47 PM UTC

Hai James,
You can highlight the cell contents when the user enters in edit mode by using the ActivateCurrentCellBehaviour property as shown in the following code snippet.

Code snippet[C#]:

this.dataGrid.Model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.SelectAll | GridCellActivateAction.DblClickOnCell;

 

Please let us know if you have any queries,

Regards

Deepak raj Sundar




Loader.
Up arrow icon