C1FlexGrid - 改变"突出显示"一系列单元格的行为

时间:2015-07-13 20:37:11

标签: vb.net c1flexgrid

我的情景:

我有一个带列和行标题的C1FlexGrid。此外,C1FlexGrid的第一行是布尔行(复选框)。根据这些复选框的状态,所需的效果是禁用该列的单元格。困难在于,由于第一行是不能禁用的布尔数据类型,因此使用.Cols(index).AllowEditing属性不是一个选项。我已经使用BeforeEdit事件处理程序成功实现了一个解决方法,禁止更改列中的单元格,以及CellStyle在禁用时使单元格变灰。

Private Sub C1FlexGrid1_BeforeEdit(ByVal sender As Object, ByVal e As C1.Win.C1FlexGrid.RowColEventArgs) Handles C1FlexGrid1.BeforeEdit
    If e.Row > 1 And Me.C1FlexGrid1.Item(1, e.Col) = False Then e.Cancel = True
End Sub

Private Sub C1FlexGrid1_AfterEdit(ByVal sender As Object, ByVal e As C1.Win.C1FlexGrid.RowColEventArgs) Handles C1FlexGrid1.AfterEdit
    If e.Row = 1 And Me.C1FlexGrid1.Item(1, e.Col) = False Then
        Call FormatColAsDisabled(e.Col)
    ElseIf e.Row = 1 And Me.C1FlexGrid1.Item(1, e.Col) = True Then
        Call FormatColAsEnabled(e.Col)
    End If
End Sub

Private Sub FormatColAsDisabled(ByVal col As Integer)
    Dim color As C1.Win.C1FlexGrid.CellStyle
    color = Me.C1FlexGrid1.Styles.Add("Gray")
    color.BackColor = Drawing.Color.Gray

    For row As Integer = 2 To Me.C1FlexGrid1.Rows.Count - 1
        Me.C1FlexGrid1.SetCellStyle(row, col, color)
    Next
End Sub

Private Sub FormatColAsEnabled(ByVal col As Integer)
    For row As Integer = 2 To Me.C1FlexGrid1.Rows.Count - 1
        Me.C1FlexGrid1.SetCellStyle(row, col, Me.C1FlexGrid1.Styles("Normal"))
    Next
End Sub

我的问题

有没有办法修改"突出显示"仅针对这些细胞的行为,以便禁用的细胞根本不突出显示?

0 个答案:

没有答案