Articles in this section
Category / Section

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

1 min read

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

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied