我设置treeview.Checkboxes = True会让每个treeview的节点前都出现访框进行选择 能否做到某些有方框,某些没呢?这个不行。 Option ExplicitPrivate Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Const GWL_STYLE = -16& Private Const TVM_SETBKCOLOR = 4381& Private Const TVM_GETBKCOLOR = 4383& Private Const TVS_HASLINES = 2& Dim frmlastForm As Form Private Sub Form_Load() Dim nodX As Node Set nodX = TreeView1.Nodes.Add(, , "R", "Root") Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C1", "Child 1") Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C2", "Child 2") Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C3", "Child 3") Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C4", "Child 4") nodX.EnsureVisible TreeView1.Style = tvwTreelinesText ' Style 4. TreeView1.BorderStyle = vbFixedSingle End Sub Private Sub Command1_Click() Dim lngStyle As Long Call SendMessage(TreeView1.hWnd, TVM_SETBKCOLOR, 0, ByVal RGB(255, 0, 0)) '改变背景到红色 lngStyle = GetWindowLong(TreeView1.hWnd, GWL_STYLE) Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle - TVS_HASLINES) Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle) End Sub
楼上的,谢谢你的代码 但我试了,可能是我的节点的text长点,使的非text的区域也反白显示了
up 我设置treeview.Checkboxes = True会让每个treeview的节点前都出现访框进行选择 能否做到某些有方框,某些没呢?
能否做到某些有方框,某些没呢?这个不行。
Option ExplicitPrivate Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_STYLE = -16&
Private Const TVM_SETBKCOLOR = 4381&
Private Const TVM_GETBKCOLOR = 4383&
Private Const TVS_HASLINES = 2&
Dim frmlastForm As Form
Private Sub Form_Load()
Dim nodX As Node
Set nodX = TreeView1.Nodes.Add(, , "R", "Root")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C1", "Child 1")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C2", "Child 2")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C3", "Child 3")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C4", "Child 4")
nodX.EnsureVisible
TreeView1.Style = tvwTreelinesText ' Style 4.
TreeView1.BorderStyle = vbFixedSingle
End Sub
Private Sub Command1_Click()
Dim lngStyle As Long
Call SendMessage(TreeView1.hWnd, TVM_SETBKCOLOR, 0, ByVal RGB(255, 0, 0)) '改变背景到红色
lngStyle = GetWindowLong(TreeView1.hWnd, GWL_STYLE)
Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle - TVS_HASLINES)
Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle)
End Sub
但我试了,可能是我的节点的text长点,使的非text的区域也反白显示了
我设置treeview.Checkboxes = True会让每个treeview的节点前都出现访框进行选择
能否做到某些有方框,某些没呢?