ok here some code... don't worry about some of the code because they are functons that i have created for the project that i'm working on. The code here will help you with the loading/adding of items to the listview... I'll post a second post with the handling which is selected.
VB Code:
Friend Sub LoadProjects()
Dim cn As New OleDbConnection(GetOleDbConnection)
Dim cmd As New OleDbCommand("SELECT colldev_projects.*, colldev_users.fname, colldev_users.lname FROM colldev_users INNER JOIN colldev_projects ON colldev_users.id = colldev_projects.manager_id")
Dim dr As OleDbDataReader
cmd.Connection = cn
cmd.CommandTimeout = GetCommandTimeOut()
cn.Open()
If cn.State = ConnectionState.Open Then
dr = cmd.ExecuteReader
If dr.HasRows Then
Me.lvProjects.SuspendLayout()
Me.lvProjects.Items.Clear()
Do Until Not dr.Read
Application.DoEvents()
Dim lvitm As New ListViewItem
With lvitm
If CBool(dr("inactive")) Then
.BackColor = Color.Yellow
End If
.Tag = CStr(dr("projid"))
.Text = CStr(dr("library_name"))
With .SubItems
.Add(CStr(dr("fname")) + " " + CStr(dr("lname")))
.Add(CStr(dr("start_date")))
.Add(CStr(dr("complete_date")))
.Add(Format(CDbl(dr("est_num_items")), "###,###,###,###,##0"))
.Add(Format(CDbl(dr("proj_amt")), "###,###,###,###,##0.00"))
.Add(CBool(dr("inactive")).ToString)
.Add(CStr(dr("projid")))
.Add(CStr(dr("manager_id")))
End With
End With
Me.lvProjects.Items.Add(lvitm)
lvitm = Nothing
Loop
Me.lvProjects.ResumeLayout()
End If
End If
dr.Close()
cn.Close()
cmd.Dispose()
cn.Dispose()
dr = Nothing
cmd = Nothing
cn = Nothing
End Sub