×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Check box in Combobox

Check box in Combobox

Check box in Combobox

(OP)
Hi,

How can I put check box in a combo box??

Please guide

abbasaif

RE: Check box in Combobox

You can partially. Just like the Listbox the Combobox has the Picture property in two variations: As single property specifying a picture for all items and as Picture array.

You have to use the Combobox with its ListItem array instead of rowsourcetype cursor or fields because that doesn't mix with array index = recno() or something along these lines.
And once you have an unchecked box as image there's no automatic checking it. So you have to emulate this, and it won't suppress the usual color inversion of picked items.

I'd not go that route for mere look&feel reasons. The combobox collapses its list after a single pick anyway. A list of checked or unchecked items is best shown in a grid, where you can also put a real checkbox control into a column, that automatically acts as a checkbox and binds to a field.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Check box in Combobox

(OP)

Quote:

And if you want to know how to add a checkbox to a grid, see this article:

Yes, I am using different controls in grid.
I was wondering if I could do multiple selection.

Thanks for the reply!



Abbasaif

RE: Check box in Combobox

You can do multiple selection in a listbox (not a combo box) simply by setting the MultiSelect property to .T. To make a multiple selection, users holds down Shift and/or Ctrl keys while clicking on an item. To find which items they have selected, you use the Selected property.

But it is awkward for the user, and susceptible to errors. If you are comfortable placing checkboxes in a grid, I suggest you stay with that.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Check box in Combobox

(OP)

Quote:

You can do multiple selection in a listbox (not a combo box) simply by setting the MultiSelect property to .T. To make a multiple selection, users holds down Shift and/or Ctrl keys while clicking on an item. To find which items they have selected, you use the Selected property.

Yes, I did that also. see

abbasaif

RE: Check box in Combobox

So what speaks for a checkbox in a combo? A combobox in itself doesn't allow multiselect, it is designed for a single value it stores in its Value property and stores back into the controlsource after picking an item. Even if you manage to display unchecked and checked boxes in the dropdown list portion of a combo and disregard its value, what is your gain? Needing less place? You can shrink a listbox or grid via height, you can use pageframes, also without tabs, you can scroll a form. Just to name three things saving space. But you just cause more trouble than it's worth to include checkboxes in a combobox. I don't see any other reason to have this. Maybe you find ActiveX controls supporting such a design, but it is extremely useless in my personal opinion, even for space saving layouts.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Check box in Combobox

(OP)
Thanks for the reply!

Actually I want to put the combo box instead of text box on the top of the grid header as shown in image.
Where users can select multiple categories instead of checking each item through check box.
If user check any category, it should check all the item codes accordingly.

Thanks



Abbasaif

RE: Check box in Combobox

Ah, that at least explains the motivation.

Well, see what Excel does? It puts a dropdown arrow button within the header caption. So indeed every header at first glance looks like a combobox. But it isn't really a combobox. The dropdown simply is something like a form or container. You could do the latter in VFP, too. So don't use a combobox, just add a button there and let that show a container "dropping down" (you don't have to animate it, rather set it visible =.t. or create it at that moment). Then use a multiselect listbox in that container and two buttons OK and Cancel.

It's up to you what you show when the user closes that container with OK or Cancel. Maybe just change a button caption from "pick categories" to "picked categories" to indicate the column is actively filtering data and back to "pick categories" when no category is picked and data isn't filtered by that column filter control. A normal combobox - even if it had multi-select - would still not be able to show all picks in the one row in the collapsed state.

As your layout already differs from Excels idea to have that within the header make the best of that, you're free to do whatever you want. In case of a textbox for entering a filter value, it is even simpler to use as Excels way, but in this case, I'd just use a button. Maybe a textbox plus a button, and then an extra container, or even a form you position there, set without titlebar. Whatever, but you are not the owner of the dropdown portion of a combobox, so use something else.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Check box in Combobox

(OP)
Thanks Mr.Olaf, I got some idea from your valuable suggestion.

Let me try it!!

Abbasaif

RE: Check box in Combobox

(OP)
Yes, Mr. Olaf

I created a button inside a container which contains a grid also. Same like shown above.
Initially the container size is same as button size and no sooner it is clicked, it opens to a certain size with give and check box.

Category is selected and clicked the same button (toggle) which close the container and checked the respective item codes boxes related to the same category.

At last my I go the solution.

Thanks for the time sharing with me.

Abbasaif

RE: Check box in Combobox

Good idea.

The only thing not nice about such containers you resize or switch in their visibility is design time handling of them. I guess you created the full-size container on the form and resized it to button size after you were finished. Now to change something in this you'd need to resize the container at design time to make the change and then resize it back. (Just an assumption)

Here really OOP and creating such a container as a class of a VCX can help. You can code and design as you like, keep the container at its expanded full size, you drag&drop the class on the form and shrink it as you like and you never need to go back and forth again. Any change you do in the full-size class, the object on the form still is shrunk down.

There are also some more strategies to let such a container control its own size in itself with init already, so you don't change that manually or as I also already hinted just creating such things at runtime at first use.

A new extra form has some hurdles too, and some things the container does not: Scrollbars. But before I tear down everything you just built, I conclude with the recommendation you stick to what you have and see how it works out, then come back for a second generation redesign later with the experience made.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Check box in Combobox

(OP)
Yes, Mr. Olaf

I created this container as class and using it wherever is required in other forms.

Thanks a lot!

Abbasaif

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close