十万火急,高分求解:VB列表前加入图标的简单问题
请VB高手给我写一段VB代码,实现下述功能:fori=1t010'这里显示图标i(c:\i.gif),这里显示文字inext点击列表中图标或文字打开一个新的窗体.非常感谢...
请VB高手给我写一段VB代码,实现下述功能:
for i=1 t0 10
'这里显示图标i(c:\i.gif),这里显示文字i
next
点击列表中图标或文字打开一个新的窗体.
非常感谢.
用Listview控件或Listbox控件或其它列表类的控件实现. 展开
for i=1 t0 10
'这里显示图标i(c:\i.gif),这里显示文字i
next
点击列表中图标或文字打开一个新的窗体.
非常感谢.
用Listview控件或Listbox控件或其它列表类的控件实现. 展开
6个回答
展开全部
工程中创建两个窗体:form1,form2
form1中加一treeview(先从部件中添加"ms windows common controls 6.0 或5.0",在工具箱中就可以找到treeview控件了),imagelist,imagebox,均为默认名称
form1中贴入以下代码:
Private Sub Form_Load()
'For i = 1 To 10
'Image1.Picture = LoadPicture("c:\" & CStr(i) & ".gif")
'ImageList1.ListImages.Add i, , Image1.Picture
'Next i
'TreeView1.ImageList = ImageList1
'如果你手工向imaglist添加图,并在treeview1中设置了图像列表为imagelist1,可使用image1及以上代码
For i = 1 To 10
TreeView1.Nodes.Add , tvwChild, "openfrm" & i, CStr(i), 1
TreeView1.Nodes(i).Tag = "0"
Next i
'TreeView1.Nodes.Add [relative], [relationship], [Key], [Text], [Image], [SelectedImage]
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If Node.Tag = "1" Then
MsgBox "窗口已打开"
Exit Sub
Else
Dim newfrm As Form2
Set newfrm = New Form2
newfrm.Show
newfrm.Caption = Node.Key
'将点击项的关键字key作为新窗口的标题,
newfrm.Print Node.Text
'将点击项的文本在新窗口中显示
'如还有其它参数还可用tag传递
Node.Tag = "1"
End If
End Sub
在form2中加入以下代码:
Private Sub Form_Unload(Cancel As Integer)
For i = 1 To Form1.TreeView1.Nodes.Count
If Form1.TreeView1.Nodes(i).Key = Me.Caption Then
Form1.TreeView1.Nodes(i).Tag = "0"
End If
Next i
End Sub
form1中加一treeview(先从部件中添加"ms windows common controls 6.0 或5.0",在工具箱中就可以找到treeview控件了),imagelist,imagebox,均为默认名称
form1中贴入以下代码:
Private Sub Form_Load()
'For i = 1 To 10
'Image1.Picture = LoadPicture("c:\" & CStr(i) & ".gif")
'ImageList1.ListImages.Add i, , Image1.Picture
'Next i
'TreeView1.ImageList = ImageList1
'如果你手工向imaglist添加图,并在treeview1中设置了图像列表为imagelist1,可使用image1及以上代码
For i = 1 To 10
TreeView1.Nodes.Add , tvwChild, "openfrm" & i, CStr(i), 1
TreeView1.Nodes(i).Tag = "0"
Next i
'TreeView1.Nodes.Add [relative], [relationship], [Key], [Text], [Image], [SelectedImage]
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If Node.Tag = "1" Then
MsgBox "窗口已打开"
Exit Sub
Else
Dim newfrm As Form2
Set newfrm = New Form2
newfrm.Show
newfrm.Caption = Node.Key
'将点击项的关键字key作为新窗口的标题,
newfrm.Print Node.Text
'将点击项的文本在新窗口中显示
'如还有其它参数还可用tag传递
Node.Tag = "1"
End If
End Sub
在form2中加入以下代码:
Private Sub Form_Unload(Cancel As Integer)
For i = 1 To Form1.TreeView1.Nodes.Count
If Form1.TreeView1.Nodes(i).Key = Me.Caption Then
Form1.TreeView1.Nodes(i).Tag = "0"
End If
Next i
End Sub
展开全部
用TreeView控件实现树形列表:
dbP = App.Path & "\学生管理.mdb"
Set conn = OpenDatabase(dbP)
strSql = "select * from 班级表 Order By 系别"
Set RS = conn.OpenRecordset(strSql)
Set Nodx = TreeView1.Nodes.Add()
Nodx.Text = "班级树形表"'主树目录
Nodx.Image = "TP1" '图形列表用ImageList控件
TreeView1.LabelEdit = tvwManual
Set Nodx = TreeView1.Nodes.Add(1, tvwChild, "A", "系分类")'分树目录
Nodx.Image = "TP2" '图形列表用ImageList控件
intIndex = Nodx.Index
Do Until RS.EOF
YHID(Nodx.Index) = RS!ID
YHXB(Nodx.Index) = RS!系别
YHZY(Nodx.Index) = RS!专业
YHNJ(Nodx.Index) = RS!年级
YHRS(Nodx.Index) = RS!人数
YFDY(Nodx.Index) = RS!辅导员
YHBZ(Nodx.Index) = RS!备注
Set Nodx = TreeView1.Nodes.Add("A", tvwChild)
Nodx.Text = RS!系别 & " " & RS!专业 & "专业" '树底层目录
Nodx.Image = "TP3" '图形列表用ImageList控件
Nodx.Tag = "Site"
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
conn.Close
Set conn = Nothing
Nodx.EnsureVisible
TreeView1.StartLabelEdit
dbP = App.Path & "\学生管理.mdb"
Set conn = OpenDatabase(dbP)
strSql = "select * from 班级表 Order By 系别"
Set RS = conn.OpenRecordset(strSql)
Set Nodx = TreeView1.Nodes.Add()
Nodx.Text = "班级树形表"'主树目录
Nodx.Image = "TP1" '图形列表用ImageList控件
TreeView1.LabelEdit = tvwManual
Set Nodx = TreeView1.Nodes.Add(1, tvwChild, "A", "系分类")'分树目录
Nodx.Image = "TP2" '图形列表用ImageList控件
intIndex = Nodx.Index
Do Until RS.EOF
YHID(Nodx.Index) = RS!ID
YHXB(Nodx.Index) = RS!系别
YHZY(Nodx.Index) = RS!专业
YHNJ(Nodx.Index) = RS!年级
YHRS(Nodx.Index) = RS!人数
YFDY(Nodx.Index) = RS!辅导员
YHBZ(Nodx.Index) = RS!备注
Set Nodx = TreeView1.Nodes.Add("A", tvwChild)
Nodx.Text = RS!系别 & " " & RS!专业 & "专业" '树底层目录
Nodx.Image = "TP3" '图形列表用ImageList控件
Nodx.Tag = "Site"
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
conn.Close
Set conn = Nothing
Nodx.EnsureVisible
TreeView1.StartLabelEdit
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用树可以实现.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
树能实现,而且比较全面.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
I DONT KNOW
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个还真不会~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询