Articles in this section

How to restrict the columns from being removed from the WinForms GridControl?

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 WinForms GridControl via the ColsRemoving event.

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;
    }
}
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 WinForms gridcontrol


Samples:

C#: Deleting Column-C#

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