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

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

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: February 12, 2016
Tags: selection

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

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
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

Please sign in to access our KB

This page will automatically be redirected to the 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