)
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 restrict the columns from being removed from the WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: April 13, 2015 |
Last Revised Date: December 18, 2019

Deletion of column

To restrict the columns from being deleted, you can cancel the ColsRemoving event. In the given example, the deletion of columns is controlled through a CheckBox via the ColsRemoving event.

C#

private void button1_Click_1(object sender, EventArgs e)
{
    //Removes a range of columns.
    this.gridControl1.Cols.RemoveRange(1, 1);
}
void gridControl1_ColsRemoving(object sender, GridRangeRemovingEventArgs e)
{
    if (checkBox1.Checked)
    {
        //Disables deletion.
        e.Cancel = true;
    }
}

VB

Private Sub button1_Click_1(ByVal sender As Object, ByVal e As EventArgs)
  'Sets a Range for deleting column.
  Me.gridControl1.Cols.RemoveRange(1,1)
End Sub
Private Sub gridControl1_ColsRemoving(ByVal sender As Object, ByVal e As GridRangeRemovingEventArgs)
  If checkBox1.Checked Then
 'Disables deletion.
 e.Cancel = True
  End If
End Sub

 

In the following screenshot, to disable the column from being deleted, you can enable the check box. This restricts the column from being removed.

Restrict the deleted column in gridcontrol

Samples:

C#: Deleting Column-C#

VB: Deleting Column-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