c1FlexGrid列启用禁用

时间:2014-08-01 14:44:57

标签: c1flexgrid

我在Windows窗体上使用C1FlexGrid。

我在网格中有SELECT列,类型为Checkbox。

表格上的网格外有一个编辑按钮。

最初,我希望禁用网格中的“选择”列。

单击“编辑按钮”后,我希望启用“选择”列(以便可以为每行勾选)

按完保存后,我想再次禁用选择列。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我假设您已通过将columns数据类型更改为boolean来在C1lexGrid列中使用CheckBoxes。很容易阻止用户与C1FlexGrid中的特定列进行交互。请参阅以下代码段:

<强> 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