I have a listbox with some columns as checkboxes.
the columns are not editable, but when I click on the checkboxes, they turn on and off
is there a way to have non-clickable checkboxes inside a listbox ?
(e.g. a click does nothing except select the row even a click on a checkbox)
I’ve done this too - Sometimes I want a checkbox to indicate a boolean that is determined by the system, not the user. For example, in a customer database, there are some customers that have given us permission to call them on the phone and some that haven’t. This value should not be modifyable by the user, but should display a checkmark to indicate which customers can be called.
You could just display an icon of a checkmark, but a checkbox often looks more consistent in the UI.
Because in that instance the boolean is not changeable by the user I would probably have chosen to use an icon to indicate the customer can be called in that situation.
right - a picture would be good but IF you want the right OS look for that picture DrawInto can be used to draw a checked checkbox into an image that can be used as the picture for the row
Its no longer clickable but looks like a checkbox should for that version of the OS etc
That would mean a change in spec, which would mean at least a 24 hour delay to get client approval. Then you have to notify the documentation team, and it all ends up to be more time and trouble than it’s worth.
I have a similar situation and use the following code:
'if app is not available or if we are in the StartupWindow there is no cellcheck
if AppFolderitem = nil or raiseEvent IsStartupWindow then
me.CellCheck(row, 0) = not me.CellCheck(row, 0)
Return
end if
it is to display some boolean values from a database
some users have the right to check the box, some others dont have the right, but they are allowed to see the value.
Following Michel( the guru)'s comment, this seems to get you mostly there (Windows) in the listbox mousedown event:
[code]
Dim r,c as Integer
Dim i as integer
'This taken from the manual
r=Me.RowFromXY(System.MouseX - Me.Left - Self.Left, System.MouseY - Me.Top - Self.Top)
c=Me.ColumnFromXY(System.MouseX - Me.Left - Self.Left,System.MouseY - Me.Top - Self.Top)
’ column 1 has checkbox
If c=1 then
'Cut this if multi-selection listbox
For i=0 to listbox1.listcount-1
Listbox1.selected(i)=false
next
Use CellClick which provides row, column. It also provides x, y so you can filter just checkbox region clicks and let others act normally. Knowing how much space to give the widget is tricky though. I used a few properties to track and compute the first CellTextPaint width minus the first CellBackGroundPaint width for a checkBoxSpan width (24 for me).
[code]Function CellClick(row as Integer, column as Integer, x as Integer, y as Integer) As Boolean
if userCantChangeCBs and me.CellType(row, column) = me.TypeCheckbox then
return x < checkBoxSpan
else
return false
end