ListBox with checkboxes that function as RadioButtons

Hi, guys,

I am curious if it is possible to create a ListBox with four columns.

First column - CRITERION
Second column - YES
Third column - NO
Fourth column - INCOMPLETE

Checkboxes in second, third, and fourth columns should work like RadioButtons (only one can be checked).

Is this possible?

Thank you in advance,

Val

Din’t use Checkboxes. Draw your own “Radiobutton”.

If they don’t have to look like radiiobuttons, then you can simply keep the rowindex of the one switched on in a variable and make a switch when the user selects the checkbox of another row by switching the one the variable is pointing to off on the action event.

If we don’t talk about hundreds or thousands of rows, uncheck all other checks in the same column uppon activation of a checkbox.

Something like this in the CellAction Event:

[code]Select Case column

Case 1

Dim X,Y As Integer
Y = Me.ListCount - 1

For X = 0 To Y

If X <> row Then

Me.CellCheck(X, 1) = False

End If

Next

End Select[/code]

Yes it’s technically possible, you’d make each column contain a checkbox and when a cell is clicked, you simply uncheck the other boxes in that row.

However as Markus says; doing this is going against human interface guidelines. While it may solve your purpose, it’s not what people are used to, and therefore it’s recommend that you use Radio Buttons instead. Xojo doesn’t support Radio Buttons in a listbox, but with some custom drawing, you can easily add your own. You can then use the rowTag to hold the value of which radio button is selected.

Alternatively you could just use Unicode Symbols like this: https://unicode-table.com/en/1F518/

Or you can be creative using for example a black / white star inside a grey circle (or othe stuff)…

Or use light green for ON and light red for OFF ?
All depends on your current interface…

Hello, everyone,

Thank you very much for all your replies. I am checking this forum before leaving for work.

I will need to play with all you suggested solution and find one that I could implement and that would be intuitive for the user.

The listbox is going to be used for assessment of students’ performances via direct observation such as:

  1. student auscultated lungs with stethoscope on the skin YES NO INCOMPLETE
  2. student asked patient about allergies YES NO INCOMPLETE

The only reason I am considering checkboxes/radiobuttons in the cells is that some actions have a standard value for YES (1 point) and different value for NO (-5 point).

For example, for washing hands before performing physical exam YES has value of 1 point, but for NOT washing hands students are penalized with minus 5 points.

I am considering changing the checklist into the negative statement such as

student DID NO WASH hands before physical exam - YES (-5) points, and leave NO at the default (0 points).

In this case, the checklist would be easier to implement and performance score calculation would be easier.

Still, some of my colleagues might find negative statement in the list of students’ expected performances confusing for the faculty.

One of my goals with this project is to make this app as uncluttered, intuitive, and easy to use as possible.

Thank you again. If anyone has any suggestions, I always welcome and appreciate good ideas.

Val

Answer to Sascha S,

Hi, Sascha,

Thank you for the code suggestion. I need to have radiobuttons (or whatever is used instead of them) unchecked in the rows.

This means, for each criterion only YES, NO, or INCOMPLETE could be selected.

Thank you again for all you help.

I am leaning toward using a graphics for checked/unchecked states of the cells.

The cells will have numeric values such as YES (2), NO (0), INCOMPLETE (1)

I will need to find a way to display only the graphics in the cells (raiobuttons) but hide the values to keep GUI uncluttered.

Still an algorithm in the background will need to be able to calculate the scores.

Thank you again,

Val

Hi, Sascha,

I am considering using cell’s background as an indicator of being selected.

By default, all cells in a row will be of the same color.

When the second cell in the row (YES) is clicked, the cell’s background will change to GREEN; when the third cell (NO) is clicked, the cell’s background will change to RED; when the fourth cell in the row (INCOMPLETE) is clicked, the cell’s background will change to ORANGE.

I think it will be easier to use than checkboxes and radiobuttons.

Any thoughts? Will this be user-friendly?

Thank you,

Val

the best here for user-friendly is to use radio buttons !

Just an idea to get you started. :slight_smile:

Create a Listbox with 6 Columns. Write a few rows with something like “Answer 1,0,Answer 2,1,Answer 3,0”.

In the CellClick Event put:

[code]If row > -1 And row < Me.ListCount Then

Select Case column

Case 1,3,5

Dim a As Integer
For a = 1 To 5 Step 2

Me.Cell(row, a) = “0”

Next

Me.Cell(row, column) = “1”

End Select

End If[/code]

and in the CellTextPaint Event:

[code]If row > -1 And row < Me.ListCount Then

Select Case column

Case 1,3,5

If Me.Cell(row,column) = “1” Then

g.FillOval(2,2, 12,12)

Else

g.DrawOval(2,2, 12,12)

End If

Return True

End Select

End If[/code]

Dear Sascha,

Thank you for the code. It works perfectly. I learned a lot from it.

When I have a semi-complete app, I will put it into a dropbox so that you and everyone else could take a look at it.

The actual app is a bit more complex than I previously described. Actually, there are two applications:

  1. Checklist Creator
  2. Checklist Player

Checklist Creator is designed to create a checklist with values attached to each item. Items might have different values, not just “1” for YES, and “0” for “NO”

The Checklist Creator creates a coma-separated text file with the Parameter Names and their values.

The Checklist Player opens a coma-separated text files, and populates its listbox with parameter names and their values.

Teachers will observe students’ behaviors and use the listbox to keep track of what is done. The Checklist Player will count all points earned by students and generate a score based on the formula:

Score = “Earned Points”/“Maximum Possible Points”*100

Making each parameter item to be able to have a different attached value complicates the entire thing.

Right now I have my CheckList Creator being able to generate a listbox with two columns:

1.Parameter Item
2. Value

It generates a text file that looks like this:

Asks patient about chief complaint,1
Reviews vital signs,1
Washes hands,1
Asks patient about allergies,1

When this text file is opened the CheckList Player, it populates the listbox in the CheckList Player with those values.

An educator uses the listbox with checkboxes to reflect on the student’s performance and the CheckList Player generates a teaching session report:

  1. what expected actions took place
  2. what expected actions were not performed
  3. total score

Right now, if an expected student’s action has not taken place, the score is penalized only by giving a zero point for that item.

If an expected student’s performance has taken place, the score is rewarded by giving an assigned value (it could be any integer).

Right now, it looks like this

Asks about chief complaint. YES (1) NO (0)
Asks about allergies YES (2). NO (0)
Washes hands YES (1). NO (0)

There are some actions that should give students minimal rewards if done (YES) and severe penalty if not done (NO).

For example,

Washes hands YES (1), NO (minus 5).

I envisioned the CheckList Creator to create a text file with four (4) columns

  1. Parameter
  2. YES
  3. NO
  4. INCOMPLETE

For each row there would be different values for Parameter, for YES, for NO, and for INCOMPLETE

If your suggested design is used, there would be seven (7) columns. The columns with the ANSWER in your example would need to be populated based on the values from the coma-separated text file.

Speaking about my current design (with two columns) I can see only one workaround (please take a look at the example)

Student FORGOT to wash hands YES (minus 5) No (0).

This workaround would produce a correct score but some educators might complain that the checklist contains an item of WHAT NOT TO DO in the mix of the correct and expected interventions. (Using wrong answers in the quizzes is currently considered a bad practice).

I just tried to explain where I am coming from and what challenges I have. Also, I try to keep it as simple as possible.

Thank you for reading this rather lengthy explanation.

Val