当前位置:首页 > 网络编程 > WEB编程 > ASP.net > VB中如何修改treeview的背景色

VB中如何修改treeview的背景色

点击次数:18 次 发布日期:2008-11-27 00:08:51 作者:源代码网
源代码网推荐 改变 TreeView 的背景
源代码网推荐
源代码网推荐Private 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

Option Explicit
源代码网推荐

源代码网整理以下

Private 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&

源代码网整理以下

源代码网整理以下

Private Sub Form_Load()

源代码网整理以下

源代码网整理以下

Dim nodex As Node
源代码网推荐Dim i As Integer
源代码网推荐Dim lStyle As Long

源代码网整理以下

源代码网整理以下

Call SendMessage(TreeView1.hWnd, TVM_SETBKCOLOR, 0, ByVal RGB(255, 0, 0))
源代码网推荐lStyle = GetWindowLong(TreeView1.hWnd, GWL_STYLE)
源代码网推荐Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lStyle - TVS_HASLINES)
源代码网推荐Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lStyle)

源代码网整理以下

源代码网整理以下

TreeView1.Style = tvwTreelinesPlusMinusPictureText
源代码网推荐TreeView1.BorderStyle = ccFixedSingle
源代码网推荐With TreeView1.Nodes
源代码网推荐Set nodex = .Add(, , "R", "Root")
源代码网推荐nodex.BackColor = RGB(255, 0, 0)
源代码网推荐For i = 1 To 10
源代码网推荐 Set nodex = .Add("R", tvwChild, "C" & i, "Child " & i)
源代码网推荐 nodex.BackColor = RGB(255, 0, 0)
源代码网推荐 nodex.EnsureVisible
源代码网推荐Next
源代码网推荐End With

源代码网整理以下

源代码网整理以下

End Sub

源代码网整理以下

源代码网整理以下


源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华