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

Inheritance of list property

Status
Not open for further replies.

wbeetge

Programmer
May 2, 2002
57
ZA
Can anybod tell me if one can inherit the list property from one combo control to another combo control ?

Instead of :
...
do while not .....
Combo1.additem Rs("Fieldname")
Combo2.additem Rs("Fieldname")
Combo3.additem Rs("Fieldname")
Rs.MoveNext
loop
...

I would think there would be some way to say
...
do while not .....
Combo1.additem Rs("Fieldname")
Rs.MoveNext
loop
Set Combo2.list = Combo1.list
Set Combo3.list = Combo1.list

Is this possible ?
My guess is it would be much quicker to populate than using the additem method for each control
 
I tried this. I manually populated a combo (combo1) and then iterated through and populated the combo2 with all items from the combo1 using the following loop. Simple effective, probalbly another way of doing this but it works and that the main thing


For i = 0 To 4
Combo2.List(i) = Combo1.List(i)
Next i


Hope this helps or stimulates some brain cells perhaps

Nev G
 
No, I could have done this in the first instance - of my example. - but it is too slow.

I have 470 odd entries in the database and would like to only use the additem method to get one combo or listbox filled.
The other listboxes or combos are on different tabs and need to simply say - My list is now the same as yours..(the already populated list)

So, if any addition is made to the initial loaded list, the other lists can be updated quite snappy ! myList = yourList
 
One option might be to use a DataBound ListBox or Combobox on each tab. Then all you have to do is add a record to the table and refresh the list.

As a desperate measure you could have one combobox on the main form. Then in the click event of the tab control, you could move the combobox to the place on the screen you need it and then make it visible. If you have a tab that doesn't need the combobox, just set its visible property to false. If you take this apporach, you have to add the combobox to the form and then move it over the tabbed dialog box. You can't leave it on the tab control. But I'd use this as a desperate mesasure only. Snaggs
tribesaddict@swbell.net
Life can only be understood backwards; but it must be lived forwards.
 
For one thing, do not reference the recordset three times.
Dim strItem as string
strItem = Rs("Fieldname")
Combo1.additem strItem
Combo2.additem strItem
Combo3.additem strItem
Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
One other thought. If the Sorted property = true then it might be faster if the second and third boxes were filled from the first in reverse order because the next item to be inserted will always land in the (0) element.
For I = combo1.Listcount - 1 to 0 step 1
strItem = combo1.list(I)
Combo2.additem strItem
Combo3.additem strItem
Next
Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Not a bad idea.

I will definitely use the variable option

But still, the list should be an object that could be inherited - not so ? (what do you think ?)
 
Not in VB6. That is not inheritance. That is just being able to copy a reference. Even in VB.Net, the Items Collection property is ReadOnly. If you were on frames instead of tabs, then one list would suffice because you can "move" an object between frames just by setting the objects Container property to a new frame. Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Hi John.

Yes, I hear what you are saying. Seems pretty shortsighted to me.
Is there nothing that I can do - Read the data into a collection or array first and then somehow get the list to take it on as the list ?
 
The MS Forms list control supports the ability to read an array from and assign an array to the List property - and will allow you to meet your requirements.

I'm still trying to figure out a way to do it with the intrinsic control...
 
Hi,
U can try using this approach.
First create a listbox with index 0 in design time ant at run time populate it.

and now if we go by the theory of creating controll at run time.The new list that u will create at run time should have all the properties of the first instance.

I have not tried it my self but u can give it a try.

Hope it helps
 
Tried that already and it didn't work. Snaggs
tribesaddict@swbell.net
Life can only be understood backwards; but it must be lived forwards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top