Current Situation
I display a list of conveyors that contain custom options. When multiple conveyors are selected, I show the uncommon options as an indeterminate state like so:
This demonstrates that the conveyors EB-1 and EB-3 do not have the same custom options (Test and Test2).
Goal
I'd like the user to be able to click on the indeterminate state and set it to false or true. When the user interaction occurs, I don't want the indeterminate state to happen.
Option Load with ThreeState Mapping
Public Enum TriState
Common
TurnedOn
TurnedOff
End Enum
Private Sub LoadCustomOptions()
ViewOptions.Table = DataSet1.CustomOptions
With dgvOptions
.DataSource = ViewOptions
'Add checkbox
Dim ChkBox As New DataGridViewCheckBoxColumn
ChkBox.Name = "ColChk"
ChkBox.HeaderText = ""
ChkBox.MinimumWidth = 20
ChkBox.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
ChkBox.ThreeState = True
ChkBox.TrueValue = TriState.TurnedOn
ChkBox.FalseValue = TriState.TurnedOff
ChkBox.IndeterminateValue = TriState.Common
ChkBox.ValueType = GetType(TriState)
ChkBox.DisplayIndex = 0
'Width
.Columns("Name").AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
.Columns("Description").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
'Minimum Width
.Columns("Description").MinimumWidth = 150
.Columns.Add(ChkBox)
End With
End Sub
Attempt
Here's what I tried:
Private Sub dgvOptions_CellContentClick(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvOptions.CellContentClick
If e.RowIndex < 0 Then Exit Sub
If dgvOptions.Columns(e.ColumnIndex).Name = "ColChk" Then
If dgvOptions.Rows(e.RowIndex).Cells("ColChk").Value = TriState.TurnedOn Or dgvOptions.Rows(e.RowIndex).Cells("ColChk").Value = TriState.Common Then
dgvOptions.Rows(e.RowIndex).Cells("ColChk").Value = TriState.TurnedOff
Else
dgvOptions.Rows(e.RowIndex).Cells("ColChk").Value = TriState.TurnedOn
End If
End If
End Sub
I still get the indeterminate state when the user clicks on the custom options checkbox. Is there an another way to approach this that I'm ignoring?