|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
在此正好向大家求助一些问题:
最近在学树控件,有三个问题学不会,一个是窗体打开时树枝全部显示,没隐藏;二是树枝显示与隐藏不能确定为单击一种方法,有时单击有时双击触发变化有时没反应;三是单击节点不能弹出另外的窗体,没反应。代码:
Private Sub UserForm_Initialize()
Dim nod As Node
Dim lngStyle As Long
With TreeView1.Nodes
Set nod = .Add(, , "爷", "请选择评测对象")
nod.BackColor = RGB(204, 255, 255)
Set nod = .Add("爷", TvwChild, "父1", "贷款利率浮动幅度测算")
nod.BackColor = RGB(0, 255, 255)
Set nod = .Add("爷", TvwChild, "父2", "农户资信等级评测")
nod.BackColor = RGB(0, 255, 255)
Set nod = .Add("爷", TvwChild, "父3", "企业资信等级评测")
nod.BackColor = RGB(0, 255, 255)
Set nod = .Add("爷", TvwChild, "父4", "家庭农场等级评测")
nod.BackColor = RGB(0, 255, 255)
Set nod = .Add("爷", TvwChild, "父5", "专业合作社等级评测")
nod.BackColor = RGB(0, 255, 255)
Set nod = .Add("父1", TvwChild, "子1", "测算数据维护")
nod.BackColor = RGB(51, 204, 255)
Set nod = .Add("父1", TvwChild, "子2", "测算文件查阅")
nod.BackColor = RGB(51, 204, 255)
nod.EnsureVisible
End With
Call SendMessage(TreeView1.hWnd, TVM_SETBKCOLOR, 0, ByVal RGB(204, 255, 255))
lngStyle = GetWindowLong(TreeView1.hWnd, GWL_STYLE)
Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle - TVS_HASLINES)
Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle)
End Sub
Private Sub Treeview_NodeClick(ByVal Node As Object) (注: 'Object换成MSComctlLib.Node也不行)
If TreeView1.Node.Text = "测算数据维护" Or Treeview1.Node.Key Like = 子2" Then(注: 'node换成select...也不行)
UserForm4.Show
End If
End Sub |
|