Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / May 2004



Tip: Looking for answers? Try searching our database.

2 ComboBoxes and ListIndex

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark - 31 May 2004 15:30 GMT
Hi,

I am programming in VB now for schoolproject. I have 2 comboboxes..
only 1 (cmbKand) is changable. I fille both comboboxes at the same
time, using the following code:

   While Not rsCmbKlant.EOF
       cmbKlant.AddItem rsCmbKlant!Klant_Achternaam & ", " &
rsCmbKlant!Klant_Voornaam
       cmbKlant.ListIndex = 0
       
       cmbKlantID2.AddItem rsCmbKlant!KlantID
       cmbKlantID2.ListIndex = 0
               
       rsCmbKlant.MoveNext
   Wend

cmbKlant 1 has the name of a customer, and cmbKlantID2 has the ID from
the customers. Now when I change the cmbKlant, I want cmbKlantID2
automatically to be updated

I tried something with listindexes, but nothing worked, only errors. I
hope you can help me out!!

Thanks!!!

Now I want, when I change the
Hans Eekels - 31 May 2004 19:24 GMT
Mark,

Use the Combo.ItemData to store an unique number (KlantID can be a good one,
if you don't change that number). The ItemData has the same index as the
listitem, so when you will change something in Combo1, you can find the
corresponding item with the same ItemData in Combo2.
Tip 1: be carefull with a sorted combobox; the indexes are not 0,1,2,3,4,
but perhaps 2,0,4,3,1,.. depending on the sorting. So, use this code:

Combo1.AddItem RTrim$(strAchterNaam)
Combo1.ItemData(Combo1.NewIndex) = lngBondsNummer

Combo2.AddItem Str(KlantID)
Combo2.ItemData(Combo2.NewIndex) = lngBondsNummer

Tip 2: You can set Combo1.ListIndex = 0 at the end of filling the ComboBox.
Signature

Hans Eekels (The Netherlands)
"You need at least two colours to see one thing"

www.SpecialSoftware.nl

> Hi,
>
[quoted text clipped - 23 lines]
>
> Now I want, when I change the
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.