Enable/Disable CellCheckBox?

Does someone know how I can set the ‘Enabled’ state of a CellCheckBox?

I see nothing like Listbox1.CellCheckBoxAt(row, column).enabled = false/true or Listbox1.CellEnabledAt(row, column) = false/true.

CellCheckBoxStateAt (row As Integer, column As Integer) As DesktopCheckBox.VisualStates

State is not enabled or disabled. You need to manage it yourself somehow. I typically use CellTypeAt and remove the checkbox for those cells I want to be disabled, or flip the value back in CellAction.

1 Like

A desktop checkbox has CheckBox.Enabled get/set. I want to disable/enable a checkbox in a listbox cell too. That’s also a ‘state’. VisualState has noting to do with being en-/disabled.

Here’s a sample of what I’m doing.

Public Sub CellCheckEnabledAt(extends control as DesktopListBox, row as Integer, column as Integer, assigns value as Boolean)
  if value then
    control.CellTypeAt( row, column ) = DesktopListBox.CellTypes.CheckBox
  else
    control.CellTypeAt( row, column ) = DesktopListBox.CellTypes.Normal
  end if
End Sub
1 Like

or using the cell tag with a status value and a custom paint and cell click event

Just to give you a start:

Function PaintCellText(g as Graphics, row as Integer, column as Integer, x as Integer, y as Integer) Handles PaintCellText as Boolean
  If column > 0 Then Return False
  
  If Me.CellTextAt( row, 1 ) = "Disabled" Then
    
    #If TargetWindows Then
      
      Me.CellTypeAt( row, 0 ) = DesktopListBox.CellTypes.Normal
      g.DrawingColor = Color.FillColor
      g.FillRoundRectangle( 0, 1, 13, 13, 5, 5 )
      g.DrawingColor = Color.LightGray
      g.DrawRoundRectangle( 0, 1, 13, 13, 5, 5 )
      
      Me.RefreshCell( row, 0 )
      
      // Unfortunately, the cell in my tests won't refresh.
      // Only when I select the row...
      
    #ElseIf TargetMacOS
      // Etc...
    #EndIf
    
    Return True
    
  End If
  
End Function

PaintCellText only updates if there is actual text in the cell. A simple “ “ is mostly enough.

1 Like

Just to provide an example of what I was saying with CellAction, here’s a DesktopListbox subclass that uses CellTagAt and the CellAction event to manage CellCheckBoxes.

disabled_listbox_checkboxes.xojo_binary_project.zip (7.0 KB)

1 Like

Thanks for the ideas! I went with simple example from @Anthony_G_Cyphers . Changing the type to normal and thus not showing a checkbox makes the list a lot less restless to the eye.

Still, I’ve filed this missing enabled/disabled option as a bug.

3 Likes

Thank you @Beatrix_Willius :slight_smile: I know, but it doesn’t make a difference.