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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I select all the text on clicking the cell?

In GridControl, the current cells behavior is controlled by the grid’s ActivateCurrentCellBehavior property. When the property is set to SelectAll, it selects all the text in the cell when the cell becomes the current cell.

C#

 

VB

After applying the properties, the grid is shown as follows,

Figure 1: Selects all the text in the cell

Sample Links

CS: SelectAll Text

VB: SelectAll Text

Article ID: Published Date: Last Revised Date: Platform: Control:
621 04/30/2011 02/12/2016 WinForms GridControl
Tags:
Did you find this information helpful?
Comments
Adam Bruss Aug 17, 2016
How can I select all the text in a cell when the user is editing a cell and presses Ctrl+A?
Reply
Neelakandan Kannan [Syncfusion] Aug 19, 2016

Hi Adam,

 

Thanks for using Syncfusion products.

 

 

 

Query

Select all the text in a cell when the user is editing a cell and presses Ctrl+A

 

 

Solution - 1

The reported scenario can be achieved by setting the CellType as OriginalTextBox. Please make use of below code,

 

Code snippet

this.gridControl1.TableStyle.CellType = GridCellTypeName.OriginalTextBox;

 

 

 

Solution – 2

You can also handle the CurrentCellKeyDown event to achieve the reported scenario. Please make use of below code,

 

Code snippet

 

this.gridControl1.CurrentCellKeyPress += new KeyPressEventHandler(gridControl1_CurrentCellKeyPress);

 

 

void gridControl1_CurrentCellKeyPress(object sender, KeyPressEventArgs e)

{

    if (((Control.ModifierKeys & Keys.Control) != Keys.None) && char.IsLetter('A'))

    {

        if (this.gridControl1.CurrentCell.IsEditing)

        {

            GridTextBoxCellRenderer renderer = this.gridControl1.CurrentCell.Renderer as GridTextBoxCellRenderer;

            renderer.TextBox.SelectAll();

        }

    }

}

 

 

 

Regards,

Neelakandan

Reply
Add Comment
You must log in to leave a comment

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