Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a Check box to a List box:

Status
Not open for further replies.

FoxLearner

Programmer
Aug 29, 2002
93
US
Hi all
How can I add a check box to a list box? I need the list box to ahve 2 columns, one with the names of tables and the other column with a check box, so that the user can select multiple tables at a time.
Appreciate your time and help
Thanks and regards
FoxLearner
 
I would use a grid and make it look like a listbox, but barring that and if you really have your heart set on using a listbox for this then you can take a look at this FAQ I wrote for simulating checkboxes in a listbox:

Simulating checkboxes in a listbox
faq184-3911

Slighthaze = NULL
[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
FoxLearner,

The only way I know to do that is to insert a graphic into the listbox. You will need two images: one for a checked checkbox and one for an unchecked one.

However, the whole thing would be difficult to program and clumsy to use. I like Slighthaze's idea of using a grid instead. Or, you might prefer to use my free SimpleList class, which is essentially a listview; it has built-in checkbox support (you can grab a copy from:

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
FoxLearner

This may not suit for aesthetical or other reasons but something else to consider if you go with a grid - you could use a checkbox but set its style to graphical.

When the checkbox is selected the checkbox will appear depressed as do the buttons when selected in MS Word's toolbar, otherwise it appears as normal.

You then have unlimited choice as to the .Picture property of the checkbox.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
 
FoxLearner,
Do you ever use ListView OCX ?
I think it's good solution for your question

Viet
 
Why you want to use checkbox "so that the user can select multiple tables at a time" ??
You can use a listbox with only one column that contains the names of tables and putting the multiselect's property of the listbox to .T. and than the user can select multiple tables at a time by clicking on the appropriate records and the 'ctrl' button of the keyboard.
 
Shevshenko,

You're right about being able to muli-select by holding down Ctrl. But personally I find this non-intuitive and clumsy. FoxLearner, it might be worth testing that method on your users before you adopt it.

Another option would be a 'mover', made up of two listboxes, with the ability to move items between them. But my personal preference is still for my SimpleList. I have used that in several projects and it has received good feedback from the users.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top