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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I open a list box thru a combo box 1

Status
Not open for further replies.

ixian

Programmer
Jul 13, 2001
128
US
Hey all,

I have a a sstab with 12 tabs on it.
I have a combo box on each tab(with variable about of item in it)
I wish for the user to use the combo box to select which listbox to open on the tab that they are on.

Aaron
 
I think u need not have multiple listboxes on each tab as u can use one listbox on each tab and populate the data based on the input from the combo box
 
Sunila,
Each tab is a major topic
Each item listed in the combo box is a subtopic.
The list box is the expanded definations of the subtopic.

Aaron
 
That's what I wanted to know all the time! Does the combobox open a seperate listbox for each item.

Make a control array for the listboxes.

ListBox(0)
ListBox(1)
.
.
.
ListBox(11)

Then, use the combobox's ListIndex property to show the listbox.

Code:
Option Explicit

Private LastList as integer

Private Sub Form_Load()
  Dim i as integer
  For i = 0 to 11
    '//Make all the listboxes invisible.
    ListBox(i).Visible = False
  Next
  '//Initialize last listbox index
  LastList = 0
End Sub

Private Sub Combo1_Change()
  '//Make the last visible listbox invisible
  ListBox(LastList).Visible = False
  '//Make the new listbox visible
  ListBox(Combo1.ListIndex).Visible = True
  '//Save the index of the new listbox
  LastList = Combo1.ListIndex
End Sub
[code]

This is a terrible way of doing it, but it works.

It will show only the listbox corresponding to the item you selected in the combobox.  O, yes.  Set the ComboBox's style to dropdown listbox (2) _________________
Bixarrio

e = m * (c ^ 2)
 
Bixarro,

thaks.Okay then how would you do this then since it is a huge amount of variable information?

Aaron
 
OK. You have a lot of info.

12 tabs, each having a combobox with, let's say 15 items each, which in turn have a listbox with, again 15 items for each item in the comboboxes.

That gives us 12 * (15 * 15) = 2700!!

First of all, in a case like this, I would use a treeview control instead. But that's because of personal preferance.

The treeview can replace the SSTab as well as the ComboBoxes, and if you're gonna display more info for the listboxes, them too.
However, as I understand your question, it will only be the SSTab and the comboboxes.
Code:
+ Topic 1
|   + Subtopic 1 of Topic 1
|   + Subtopic 2 of Topic 1
+ Topic 2
|   + Subtopic 1 of Topic 2
|   + Subtopic 2 of Topic 2
+ Topic 3
    + Subtopic 1 of Topic 3
    + Subtopic 2 of Topic 3
This will work the same as the SSTab and Combobox combination.

My solution won't make the entries less, but I think it would be easier to work with the treeview.
_______________________________________________________

You can fill the listboxes from a db or from a text file.

You can usse 1 listbox, instead of many, which you can fill "on the fly".

Find the data (definitions) that goes with the combo's listindex, and put it in the listbox. _________________
Bixarrio
e = m * (c ^ 2)
 
bixarro,

Okay thanks a lot again. I will fill a Access db with all the topics(as tables) and the subtopics(as fields). I tried the treeview option and when I run the main form it stated that the procedure was to large.

Aaron
 
bixarro,

Okay I have most of the db's done.

How to load them?

Aaron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top