c1FlexGrid Column Enable Disable

5.3k Views Asked by At

I am using C1FlexGrid on windows forms.

I have SELECT column in the grid which of type Checkbox.

I have an edit button outside the grid on the form.

Initially I want the Select column in the grid to be disabled.

Upon clicking Edit Button, I want the Select column to be enabled (so that it can be ticked for each row)

Once I press save, I want to disable Select Column again.

Any idea ?

1

There are 1 best solutions below

0
On

I am assuming that you have used CheckBoxes in a C1lexGrid column by changing the columns datatype to boolean. It is very easy to stop the user from interacting with a particular column in C1FlexGrid. Refer the following snippet:

C#

// Assuming the checkboxes are in column 1
private void Save_Click(object sender, EventArgs e)
{
  //...
  // Save the flexgrid..
  //...
  // disable the column
  this.c1FlexGrid1.Cols[1].AllowEditing = false;
  this.c1FlexGrid1.Cols[1].AllowDragging = false;
  this.c1FlexGrid1.Cols[1].AllowFiltering = C1.Win.C1FlexGrid.AllowFiltering.None;
  this.c1FlexGrid1.Cols[1].AllowSorting = false;
}

private void Edit_Click(object sender, EventArgs e)
{
  this.c1FlexGrid1.Cols[1].AllowEditing = true;
  this.c1FlexGrid1.Cols[1].AllowDragging = true;
  this.c1FlexGrid1.Cols[1].AllowFiltering = C1.Win.C1FlexGrid.AllowFiltering.None;
  this.c1FlexGrid1.Cols[1].AllowSorting = true;
}

VB

'Assuming the checkboxes are in column 1
Private Sub Save_Click(sender As Object, e As EventArgs) Handles Save.Click
 '...
 ' Save the flexgrid..
 '...

 ' disable the column
 Me.c1FlexGrid1.Cols(1).AllowEditing = False
 Me.c1FlexGrid1.Cols(1).AllowDragging = False
 Me.c1FlexGrid1.Cols(1).AllowFiltering = C1.Win.C1FlexGrid.AllowFiltering.None
 Me.c1FlexGrid1.Cols(1).AllowSorting = False
End Sub

Private Sub Edit_Click(sender As Object, e As EventArgs) Handles Edit.Click
 Me.c1FlexGrid1.Cols(1).AllowEditing = True
 Me.c1FlexGrid1.Cols(1).AllowDragging = True
 Me.c1FlexGrid1.Cols(1).AllowFiltering = C1.Win.C1FlexGrid.AllowFiltering.None
 Me.c1FlexGrid1.Cols(1).AllowSorting = True
End Sub