)
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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to move the current cell to edit mode with selecting all text in cell while clicking on second time in WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: February 15, 2016 |
Last Revised Date: December 17, 2019

Editing mode

In order to move the current cell to edit mode with selecting all text in second click, TableControlMouseDown event can be used and the cell text can be selected using GridTextBoxCellRenderer.

C#

this.gridGroupingControl1.TableControlMouseDown+=gridGroupingControl1_TableControlMouseDown;
void gridGroupingControl1_TableControlMouseDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlMouseEventArgs e)
{
   GridCurrentCell currentCell= e.TableControl.CurrentCell;
   int row, col;
   if(e.TableControl.PointToRowCol(e.Inner.Location,out row,out col))
   {
      if(currentCell.RowIndex.Equals(row)&& currentCell.ColIndex.Equals(col))
      {
         currentCell.BeginEdit();
         GridTextBoxCellRenderer textRenderer= currentCell.Renderer as GridTextBoxCellRenderer;
         textRenderer.TextBox.SelectAll();
      }
   }
}

VB

AddHandler gridGroupingControl1.TableControlMouseDown, AddressOf gridGroupingControl1_TableControlMouseDown
Private Sub gridGroupingControl1_TableControlMouseDown(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlMouseEventArgs)
   Dim currentCell As GridCurrentCell = e.TableControl.CurrentCell
   Dim row, col As Integer
   If e.TableControl.PointToRowCol(e.Inner.Location,row,col) Then
      If currentCell.RowIndex.Equals(row) AndAlso currentCell.ColIndex.Equals(col) Then
         currentCell.BeginEdit()
         Dim textRenderer As GridTextBoxCellRenderer=TryCast(currentCell.Renderer, GridTextBoxCellRenderer)
         textRenderer.TextBox.SelectAll()
    End If
  End If
End Sub

 

Screenshot

Current cell to edit mode in second click

Samples:

C#: SelectAllText_in_SecondClick_CS

VB: SelectAllText_in_SecondClick_VB

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

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

Live Chat Icon For mobile
Live Chat Icon