0

我在 Windows 窗体上使用 C1FlexGrid。

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

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

最初,我希望禁用网格中的 Select 列。

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

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

任何想法 ?

4

1 回答 1

0

我假设您通过将列数据类型更改为布尔值,在 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
于 2014-08-04T06:50:32.657 回答