How to bind listview?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi everyone!

does anyone know how to bind a listview to a table so that it displays the result of a particular query?
I tried using a reader but it does not work. This is the first time am using a listview so please help!!! :)

thanks Alot!
 
FJ,

this works for me


***************************************************
Public Sub FillListView(ByVal sender As System.Object, ByVal e As
System.EventArgs)

Dim iID As Integer

Dim i As Integer

Dim oListViewItem As ListViewItem

If moDataset.Tables.Count <> 0 Then

For i = 0 To moDataset.Tables.Item(0).Rows.Count - 1

If iID <> CType(moDataset.Tables.Item(0).Rows.Item(i)("PLANNING_ID"),
Integer) Then

oListViewItem = New
ListViewItem(CType(moDataset.Tables.Item(0).Rows.Item(i)("PLANNING_ID"),
String))

oListViewItem.SubItems.Add(CType(moDataset.Tables.Item(0).Rows.Item(i)("BART
EXT"), String))

oListViewItem.SubItems.Add(CType(moDataset.Tables.Item(0).Rows.Item(i)("STAR
TTIJD_GEPLAND"), String))

oListViewItem.SubItems.Add(CType(moDataset.Tables.Item(0).Rows.Item(i)("EIND
TIJD_GEPLAND"), String))

Me.lstPlanning.Items.Add(oListViewItem)

iID = CType(moDataset.Tables.Item(0).Rows.Item(i)("PLANNING_ID"), Integer)

oListViewItem = Nothing

End If

Next

Me.lstPlanning.Items.Item(0).Selected = True

Me.UpdateStatus("Planning loaded.")

Else

Me.UpdateStatus("No planning found.")

End If

Cursor.Current = Cursors.Default



End Sub



***************************************************

Marc

FJ said:
hi everyone!

does anyone know how to bind a listview to a table so that it displays the result of a particular query?
I tried using a reader but it does not work. This is the first time am
using a listview so please help!!! :)
 
Thanx a lot for the code Marc!
However, one thing i dont understand is what the sub items are exactly doing since when i tried it, only the item was displayed not the sub items..
Also the listview does not display the values in a column format. How do you assign the values returned by the query to a column
Would really appreciate it if u could help me through this.... :)
 
We created the listview column design time
That should help you

FJ said:
Thanx a lot for the code Marc!
However, one thing i dont understand is what the sub items are exactly
doing since when i tried it, only the item was displayed not the sub
items...
Also the listview does not display the values in a column format. How do
you assign the values returned by the query to a column?
 
Back
Top