我不知道如何在listview
中添加图标。我的imagelist
在其集合中有一个.ico项。我的代码到现在为止。
Private Sub filllvwStudentColumnHeaders()
' add a column width 140 and left alignment
lvwStudent.Columns.Add("User ID", 140, HorizontalAlignment.Left)
lvwStudent.Columns.Add("Lastname", 140, HorizontalAlignment.Left)
lvwStudent.Columns.Add("Firstname", 140, HorizontalAlignment.Left)
lvwStudent.Columns.Add("Middle Initial", 140, HorizontalAlignment.Left)
lvwStudent.Columns.Add("User Level", 140, HorizontalAlignment.Left)
lvwStudent.Columns.Add("User Name", 140, HorizontalAlignment.Left)
lvwStudent.Columns.Add("Password", 140, HorizontalAlignment.Left)
End Sub
Private Sub FilllvwStudent()
Dim sql = "select 1 user_id,'micevski' lastname, 'sasko' firstname, 'sm' midle, '1' level, 'sasko1' username,'123' password from test union select 2 user_id,'micevski1' lastname, 'sasko1' firstname, 'sm1' midle, '11' level, 'sasko11' username,'1231' password from test"
Dim j As Integer
Dim r As System.Data.OleDb.OleDbDataReader
Dim Conn As New System.Data.OleDb.OleDbConnection(ConnectionString)
Conn.Open()
Dim Cmd As New System.Data.OleDb.OleDbCommand(sql, Conn)
r = Cmd.ExecuteReader(CommandBehavior.CloseConnection)
If r.HasRows Then
While r.Read()
With lvwStudent.Items.Add(r("User_id"))
.SubItems.add(r.GetValue(1))
.subitems.add(r.GetValue(2))
.subitems.add(r.GetValue(3))
.subitems.add(r.GetValue(4))
.subitems.add(r.GetValue(5))
.subitems.add(r.GetValue(6))
End With
End While
End If
End Sub
我尝试的是
lvwStudent.LargeImageList = ImageList1
lvwStudent.Items.Add("ok1", 0)
0
表示imagelist
中的图片索引为0
。
此代码将“ok1”添加到列表中,但没有图标...
我开始认为这不可能在vs 2003中完成,希望有人能帮助我这样做。