M
Martin Panggabean
Hello All,
I've kind a logic problem ... I want to fill the listView control in VB.NET
with data in my mySql table using Datareader object component. But It seems
that the way of how listView being used is quite different from usual
column-row component like Grid component. If you kind a familiar using
listView, u must have known what i'm talking about. Here is some example i
took from MSDN :
----------------------------------------------------------------------------
---------
Dim item1 As New ListViewItem("item1", 0)
item1.SubItems.Add("1")
item1.SubItems.Add("2")
item1.SubItems.Add("3")
Dim item2 As New ListViewItem("item2", 1)
item2.SubItems.Add("4")
item2.SubItems.Add("5")
item2.SubItems.Add("6")
Dim item3 As New ListViewItem("item3", 0)
item3.SubItems.Add("7")
item3.SubItems.Add("8")
item3.SubItems.Add("9")
' Create columns for the items and subitems.
listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left)
listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left)
listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left)
listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
'Add the items to the ListView.
listView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
----------------------------------------------------------------------------
-----------
the result on listView control :
------------------------------------------------------
Item Columnt | Column 2 | Column 3 | Column 4
------------------------------------------------------
Item1 1 2 3
Item2 4 5 6
Item3 7 8 9
the problem is that I want to fill the listView control by using While
looping ....
While dr.read() ---- datareader component containing 4 columns and many rows
of data
..... fill the listView
End While
If only I know and it possible to define the item object inside the loop it
might solve the problem ..... or maybe you guys have a different logic to
solve this, i would appreciate it much
Thx
Martin
- newbie in VB.Net
I've kind a logic problem ... I want to fill the listView control in VB.NET
with data in my mySql table using Datareader object component. But It seems
that the way of how listView being used is quite different from usual
column-row component like Grid component. If you kind a familiar using
listView, u must have known what i'm talking about. Here is some example i
took from MSDN :
----------------------------------------------------------------------------
---------
Dim item1 As New ListViewItem("item1", 0)
item1.SubItems.Add("1")
item1.SubItems.Add("2")
item1.SubItems.Add("3")
Dim item2 As New ListViewItem("item2", 1)
item2.SubItems.Add("4")
item2.SubItems.Add("5")
item2.SubItems.Add("6")
Dim item3 As New ListViewItem("item3", 0)
item3.SubItems.Add("7")
item3.SubItems.Add("8")
item3.SubItems.Add("9")
' Create columns for the items and subitems.
listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left)
listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left)
listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left)
listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
'Add the items to the ListView.
listView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
----------------------------------------------------------------------------
-----------
the result on listView control :
------------------------------------------------------
Item Columnt | Column 2 | Column 3 | Column 4
------------------------------------------------------
Item1 1 2 3
Item2 4 5 6
Item3 7 8 9
the problem is that I want to fill the listView control by using While
looping ....
While dr.read() ---- datareader component containing 4 columns and many rows
of data
..... fill the listView
End While
If only I know and it possible to define the item object inside the loop it
might solve the problem ..... or maybe you guys have a different logic to
solve this, i would appreciate it much
Thx
Martin
- newbie in VB.Net