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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to resolve the issue of AddNewRecord not working while navigating the ReadOnly column using Tab key?

Platform: WinForms |
Control: GridDataBoundGrid(Classic)

In GridDataBoundGrid if a specific column is set to read only, it cannot be edited. The AddNewRecord for the entire grid would not be achieved excluding the readonly column.

To achieve AddNewRecords to grid except the readonly column, you need to restrict the current cell using CurrentCellStartEditing and CurrentCellActivated event for that particular column.

C#

  //Event Handler
            this.gridDataBoundGrid1.CurrentCellStartEditing += gridDataBoundGrid1_CurrentCellStartEditing;
            this.gridDataBoundGrid1.CurrentCellActivated += gridDataBoundGrid1_CurrentCellActivated;
 
void gridDataBoundGrid1_CurrentCellActivated(object sender, EventArgs e)
        {
            
            if(gridDataBoundGrid1.CurrentCell.ColIndex == 2)
                this.gridDataBoundGrid1.CurrentCell.BeginEdit();
        }
 
        void gridDataBoundGrid1_CurrentCellStartEditing(object sender, CancelEventArgs e)
        {
            //The edit mode for second column gets restricted.
            if(gridDataBoundGrid1.CurrentCell.ColIndex == 2)
            {
                this.gridDataBoundGrid1.CurrentCell.IsModified = true;
                e.Cancel = true;
            }
        }

 

VB

'Event Handler
Me.gridDataBoundGrid1.CurrentCellStartEditing += gridDataBoundGrid1_CurrentCellStartEditing
Me.gridDataBoundGrid1.CurrentCellActivated += gridDataBoundGrid1_CurrentCellActivated
 
Private Sub gridDataBoundGrid1_CurrentCellActivated(ByVal sender As Object, ByVal e As EventArgs)
 
 If gridDataBoundGrid1.CurrentCell.ColIndex = 2 Then
    Me.gridDataBoundGrid1.CurrentCell.BeginEdit()
 End If
 End Sub
 
Private Sub gridDataBoundGrid1_CurrentCellStartEditing(ByVal sender As Object, ByVal e As CancelEventArgs)
 'The edit mode for second column gets restricted.
 If gridDataBoundGrid1.CurrentCell.ColIndex = 2 Then
  Me.gridDataBoundGrid1.CurrentCell.IsModified = True
  e.Cancel = True
 End If
End Sub
 

 

Screenshot

add new record to Grid

 

 

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