Link to home
Start Free TrialLog in
Avatar of dbishop
dbishop

asked on

How to populate combobox dropdown from existing collection without looping

How to populate combobox dropdown list from existing collection without looping and display multiple columns in selection list. Maybe by using a grid as the drop down list.
Avatar of Marine
Marine

How would you ? You have to loop though a collection to populate it , i don't think there is another way.
you cant, you have to recurse through and add the items.  if you had the information in a database you can use the datacombo control though.
Avatar of dbishop

ASKER

Edited text of question.
ASKER CERTIFIED SOLUTION
Avatar of AzraSound
AzraSound
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It ain't that hard to create your own combobox, all you need is a simple textbox, a picturebox and the grid. You use the Line method to draw a pressed or unpressed button interface on the picturebox (you can not use a normal commandbutton because it will look terrible when it has the focus), in the MouseDown event draw a pressed button and in the MouseUp event draw a unpressed button. In the MouseUp event you also want to toggle the visibility of your grid. Voila! You have a combobox that has a grid as the dropdown control.
Here's the code I use to draw the button interface on the picturebox.

Public Sub DrawDown()

  'This will draw a pressed button interface
  'in the picButton picturebox, emulating a
  'real commandbutton
  picButton.Cls
  picButton.Line (0, 0)-(15, 16), vb3DShadow, B
  picButton.Line (5, 7)-Step(7, 0), vbBlack
  picButton.Line (6, 8)-Step(5, 0), vbBlack
  picButton.Line (7, 9)-Step(3, 0), vbBlack
  picButton.Line (8, 10)-Step(1, 0), vbBlack

End Sub

Public Sub DrawUp()

  'This will draw a unpressed button interface
  'in the picButton picturebox, emulating a
  'real commandbutton
  picButton.Cls
  picButton.Line (0, 0)-(0, 17), vbWhite
  picButton.Line (0, 0)-(15, 0), vb3DLight
  picButton.Line (0, 0)-(0, 16), vb3DLight
  picButton.Line (1, 15)-(15, 15), vb3DShadow
  picButton.Line (14, 1)-(14, 15), vb3DShadow
  picButton.Line (0, 16)-(15, 16), vbBlack
  picButton.Line (1, 1)-(14, 1), vbWhite
  picButton.Line (1, 1)-(1, 15), vbWhite
  picButton.Line (15, 0)-(15, 17), vbBlack
  picButton.Line (4, 6)-Step(7, 0), vbBlack
  picButton.Line (5, 7)-Step(5, 0), vbBlack
  picButton.Line (6, 8)-Step(3, 0), vbBlack
  picButton.Line (7, 9)-Step(1, 0), vbBlack

End Sub
Avatar of dbishop

ASKER

Yes, please send me an example.

I have to make a selection from a drop down list. Each row will have three columns.

my email is:
hdbishopjr@hotmail.com

Thanks,
Dave