I have an application that I am converting to vb,net. I use a list box with
multiple columns that I reference using the "list" function. How do I do this
in vb.net? The list box looks like this:
Col1 Col2 Col3
C11 C21 C31
C12 C22 C23
...
How do I build it?
How do I reference a specific column when a row is selected?
Hi John,
A list view will definately work for this. Here's an example of how I
programmically build a list view:
_____________________
lvwQuickView.BeginUpdate()
lvwList1.Columns.Add("Col1", 50, HorizontalAlignment.Left)
lvwList1.Columns.Add("Col2", 75, HorizontalAlignment.Left)
lvwList1.Columns.Add("Col3", 75, HorizontalAlignment.Left)
For Each tmpRecord In myCollection
Dim item As ListViewItem
item = lvwList1.Items.Add(New ListViewItem(New String(2)
{info1, info2, info3}))
item.Tag = tmpRecord
Next
lvwQuickView.EndUpdate()
_____________________
To reference individual columns when a row is selected:
lvwList1.SelectedItems(0).SubItems(0).Text
I hope this helps.
Michelle
John Pyle - 09 Feb 2005 21:31 GMT
This helps greatly.
After the list is built is tthere a way to select the first row. Like the
old ...Index=0?
> Hi John,
>
[quoted text clipped - 25 lines]
>
> Michelle
Michelle@bwalk.com - 09 Feb 2005 21:39 GMT
Yup, you should be able to use something like this:
lvwList1.Items(0).SubItems(0).Text
Take Care!
Michelle