Articles in this section

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

Editing mode


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

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();
      }
   }
}
AddHandler Me.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

The output is as follows:

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)
Access denied
Access denied