Click to See Complete Forum and Search --> : Menu and submenu style in a dropdown combo control?
March 3rd, 2000, 04:39 PM
Hi, I have a combobox with over 100 items which is inconvenient for a user to choose an item. So I would like to group the items into several groups and just put group name into combobox list, whenever user click the group name, I hope another temporary window pups up beside the dropdown list to show all items in that group. Can I do it? Thank very much for your help!
Ravi Kiran
March 3rd, 2000, 11:56 PM
My thinking is : doing this kind of a thing in combo would be very complex.
It will involve subclassing and a lot more, and would be quite difficult. some default behaviours would go against it!
What, i think, more easily achievable is this:
Do away with the Listbox altogether.
When user clicks on the button of the CB, you will get _dropdown event. In that event you can show a treeview control, just at the same position. But this is mimiking the "looks" only and functioning will be very different.
For Ex with a combo box you can have "click drag and select" all in one smooth motion. That sort of a thing wouldn't be possible in this case. the user has to go "click, click click"
Another possibility is a Pop-up menu. ( in VC++ ide this kind of a thing popsup at a couple of places) with all the menu structure. Instead of letting the CB show its usual listbox, we can show a pop-up menu.
The look will be totally different. But this is more easily achievable, and smooth/single motion selection is possible too.
( wow!, i was typing & thinking, and this is the first time this idea occured to me. Let me see if i can putup some code for this... )
--
I (may be others too) would be interested in how you proceed. so please post your developments..
RK
Anna Nagarajan
March 5th, 2000, 10:55 AM
I had a combo box with several items, I decided to use DBcombo instead. By setting the MatchEntry property to dbextendedMatching the user just has to type the first few letters instead of scrolling through the entire list.
Anna
March 5th, 2000, 01:49 PM
Thanks for your help.
I am geting close to what I want now. here is what I did according to your suggestion.
1) I made a hiden menu and submenu to hold all combobox items.
2) In combo1_dropdown method, call pupupmenu myMenuName.
In this way, a menu showing the group items list will show up around the combobox. But I don't know how to use APIs to RESIZE the menu to simulate a combobox dropdown list. Any more help will be greatly appreciated.
Simon
March 5th, 2000, 02:46 PM
To continue last msg...
Here is code I used in combo1.dropdown
Private Sub Combo1_DropDown()
Call PopupMenu(Menu:=mnuFile, X:=112, Y:=56)
' 112 is combo1's left position and 56 is combo1's top position
End Sub
The problem is I can't control the width of the pupupmenu. Any help?
Ravi Kiran
March 6th, 2000, 04:04 AM
well.. that is the limitation. Even i didn't realise while answering. Sorry if it caused wasted efforts.
Like i said, the looks will not be identical :-)
But you can position the Menu just at the Down-Arrow, by Right aligning with the combo: something like
[vbcode]
With Combo1
PopupMenu mnuPopup(0), vbPopupMenuLeftAlign, .Left + .Width, .Top + .Height
End With
[vbcode]
IN Windows it is also possible to open a drop-down list of a CB by pressing Alt+DownArrow when CB has focus. So you need to take care of that too.
On the plus side, you dont have to worry about positioning the lower level menu items because Windows will adjust the positions of sub menu if not enough screen space is available. (ie it will automatically show a sub menu on the left side, when there is not enough space on the right of the menu to display it. It is both an advantage and well as a disadvantage!)
---
Even i looked into MSDN. Menu doesn't have anything to get/set size, because most of the time it is determined runtime ( i think)
However i have another idea.. subclass the menu and try to set the width.. but am not sure how much of it will work. I will try for a day. So look for my post in a day or two. If something comes up or otherwise, i will post something.
If you are interested, you can try too.
Step 1: Get the Window handle of the pop-up menu item. - May not be all that easy, because i dont know offhand how to do that.
Step 2: If there exists one, then we can set the width & height.
Check back in a day please...
ps: I have tried subclassing CB before, and it is not all that easy in VB, as compared to, say, a Listbox/textbox.
VB 6.0 allows creating Controls at runtime.. i am not very sure how to leverage that .. and i dont have 6.0
RK
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.