I have list of columns in DataTable to be added in list view. I have specified to the listview of columns in the order to appear and Datas as well.
EmailAddress Subject Recieve开发者_Python百科dDate
cd@cd.in Hello 02/06/2011 23:00
This the format to appear.Please anyone can help on this
EDIT:
Code so far:
For i = 0 To objDataTable.Rows.Count drow = objDataTable.Rows(i)
Dim lvwItem As ListViewItem = New lvwItem(drow("SenderEmail"))
'lvwItem.SubItems.Add(drow("SenderEmail"))
lvwItem.SubItems.Add(drow("EmailSubject"))
lvwItem.SubItems.Add(drow("RecievedDate").ToString())
lvwItem.SubItems.Add(drow("AssignedTo").ToString())
LOV.Items.Add(lvwItem)
Next
Your code sample looks almost correct. One error is this line:
Dim lvwItem As ListViewItem = New lvwItem(drow("SenderEmail"))
This should be:
Dim lvwItem As ListViewItem = New ListViewItem(drow("SenderEmail").ToString())
Apart from that you need to make sure your listview is in details view and you actually have the columns you require (otherwise nothing will be shown when in details view):
With listview1
.View = View.Details
.Columns.Add("Email Address")
.Columns.Add("Subject")
.Columns.Add("Recived Date")
'etc
End With
One other small issue is This line:
For i = 0 To objDataTable.Rows.Count
Should be
For i = 0 To objDataTable.Rows.Count - 1
精彩评论