私のシナリオ:
列ヘッダーと行ヘッダーを持つ 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
私の質問
無効なセルがまったく強調表示されないように、これらのセルのみの「強調表示」動作を変更する方法はありますか?