)
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 make a grid cell as read-only without having the cursor when you click on the cell in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: April 19, 2015 |
Last Revised Date: February 14, 2020
Tags: readonly

Make grid cell as read-only

To make a grid cell as read-only, without having the cursor while clicking on the cell, you can cancel the TableControlCurrentCellStartEditing event. In the following code, the cursor is disabled when you click on the RecordFieldCell in the Grid.

C#

this.gridGroupingControl1.TableControlCurrentCellStartEditing += gridGroupingControl1_TableControlCurrentCellStartEditing;
//Disable Record rows being edited and disables blinking cursor inside the cell.
void gridGroupingControl1_TableControlCurrentCellStartEditing(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCancelEventArgs e)
{
    GridTableCellStyleInfo style = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex);
    if(style.TableCellIdentity.TableCellType==GridTableCellType.RecordFieldCell || style.TableCellIdentity.TableCellType==GridTableCellType.AlternateRecordFieldCell)
    {
        e.Inner.Cancel = true;
    }
}

VB

Private Me.gridGroupingControl1.TableControlCurrentCellStartEditing += AddressOf gridGroupingControl1_TableControlCurrentCellStartEditing
'Disable Record rows being edited and disables blinking cursor inside the cell.
Private Sub gridGroupingControl1_TableControlCurrentCellStartEditing(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCancelEventArgs)
   Dim style As GridTableCellStyleInfo = Me.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex)
   If style.TableCellIdentity.TableCellType=GridTableCellType.RecordFieldCell OrElse style.TableCellIdentity.TableCellType=GridTableCellType.AlternateRecordFieldCell Then
     e.Inner.Cancel = True
   End If
End Sub

 

Note:

When you are using the browse only property, you can achieve the same behavior but you cannot apply filtering to the grid.

Samples:

C#: Read-only

VB: Read-only

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
Nagaraju Dhulipalla
Aug 21, 2018
The cursor still appears even after using the code that is explained above

can you please help me to write the code to

"
to make a grid cell as read-only without having the cursor when you click on the cell?
"

Reply

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