Hier is een voorbeeldje hoe je de data van een ListBox kan opvragen:
Visual Basic:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| 'Items aan ListBox1 toevoegen
ListBox1.AddItem "Item 1"
ListBox1.Column(1, ListBox1.ListCount - 1) = "Kolom 2 van Item 1"
ListBox1.Column(2, ListBox1.ListCount - 1) = "Kolom 3 van Item 1"
ListBox1.AddItem "Item 2"
ListBox1.Column(1, ListBox1.ListCount - 1) = "Kolom 2 van Item 2"
ListBox1.Column(2, ListBox1.ListCount - 1) = "Kolom 3 van Item 2"
ListBox1.AddItem "Item 3"
ListBox1.Column(1, ListBox1.ListCount - 1) = "Kolom 2 van Item 3"
ListBox1.Column(2, ListBox1.ListCount - 1) = "Kolom 3 van Item 3"
'Tweede Item selecteren in ListBox1
ListBox1.ListIndex = 1
'Data over pompen :)
ListBox2.AddItem ""
ListBox2.List(ListBox2.ListCount - 1, 0) = ListBox1.List(ListBox1.ListIndex, 0)
ListBox2.List(ListBox2.ListCount - 1, 1) = ListBox1.List(ListBox1.ListIndex, 1)
ListBox2.List(ListBox2.ListCount - 1, 2) = ListBox1.List(ListBox1.ListIndex, 2) |
Zoals je kan zien maakt het niet uit of je
ListBox.List(Row,Column) of
ListBox.Column(Column,Row) gebruikt.
Edit: Nog wat extra info. AddItem zorgt ervoor dat het item onderaan de lijst wordt toegevoegd. Daarom gebruik ik
ListCount - 1 om de index van het laatste item te krijgen.
[
Voor 14% gewijzigd door
RayNbow op 04-06-2003 17:18
]