what i want to do is create a child
then set that child to bold.
nodX = TreeView1.Nodes.Add("r", tvwChild, Addto2, Addto2)
nodx.child.bold?
any help will be appricated
Printable View
what i want to do is create a child
then set that child to bold.
nodX = TreeView1.Nodes.Add("r", tvwChild, Addto2, Addto2)
nodx.child.bold?
any help will be appricated
Unfortunately, TreeView doesn't have a direct way of doing that, BUT...there is a workaround to achieve what you want. Here is an example:
This will add a Parent and a Child nodes, then it will make the Child node Bold.Code:Private Const TVGN_NEXT As Long = &H1
Private Const TVGN_CARET As Long = &H9
Private Type TV_ITEM
mask As Long
hItem As Long
state As Long
stateMask As Long
pszText As String
cchTextMax As Long
iImage As Long
iSelectedImage As Long
cChildren As Long
lParam As Long
End Type
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const TV_FIRST As Long = &H1100
Private Const TVM_GETNEXTITEM As Long = (TV_FIRST + 10)
Private Const TVM_GETITEM As Long = (TV_FIRST + 12)
Private Const TVM_SETITEM As Long = (TV_FIRST + 13)
Private Const TVM_SETBKCOLOR As Long = (TV_FIRST + 29)
Private Const TVM_SETTEXTCOLOR As Long = (TV_FIRST + 30)
Private Const TVM_GETBKCOLOR As Long = (TV_FIRST + 31)
Private Const TVM_GETTEXTCOLOR As Long = (TV_FIRST + 32)
Private Const TVIF_STATE As Long = &H8
Private Const TVIS_BOLD As Long = &H10
Private Sub Command2_Click()
Dim xNode As Node
Dim xChild As Node
Dim TVI As TV_ITEM
Dim lItemHwnd As Long
Dim lTreeHwnd As Long
With TreeView1
Set xNode = .Nodes.Add(, , , "Parent")
Set xChild = .Nodes.Add(xNode, tvwChild, , "Child")
xChild.EnsureVisible
End With
xChild.Selected = True
lTreeHwnd = TreeView1.hwnd
lItemHwnd = SendMessage(lTreeHwnd, TVM_GETNEXTITEM, TVGN_CARET, ByVal 0&)
If lItemHwnd > 0 Then
With TVI
.hItem = lItemHwnd
.mask = TVIF_STATE
.stateMask = TVIS_BOLD
Call SendMessage(lTreeHwnd, TVM_GETITEM, 0&, TVI)
.state = TVIS_BOLD
End With
Call SendMessage(lTreeHwnd, TVM_SETITEM, 0&, TVI)
End If
End Sub
------------------
Serge
Senior Programmer Analyst
[email protected]
[email protected]
ICQ#: 51055819
[This message has been edited by Serge (edited 02-21-2000).]
Thanks serge didn't know the call rutine..
they should incorperate a function for this control for runtime effects like this...
Thanks for your help. :cool:
[This message has been edited by BHostmeyer (edited 02-21-2000).]
Is there anyway to change the line color as well.
maybe with the TVM_SETTEXTCOLOR ?
It's not that simple, but it is possible. Instead of writing the code into the post, here is the Link to the exact answer for your question.
------------------
Serge
Senior Programmer Analyst
[email protected]
[email protected]
ICQ#: 51055819
P.S All given code was for people who doesn't have VB6. For VB6 it is very easy to do without any hassle.
------------------Code:Private Sub Command1_Click()
Dim xNode As Node
Dim xChild As Node
With TreeView1
Set xNode = .Nodes.Add(, , , "Parent")
Set xChild = .Nodes.Add(xNode, tvwChild, , "Child")
xChild.EnsureVisible
End With
With xChild
.Bold = True
.ForeColor = vbRed
End With
End Sub
Serge
Senior Programmer Analyst
[email protected]
[email protected]
ICQ#: 51055819
LOL now you tell me..
I used the childx.forecolor and it worked so i figured the other code was for vb5..
Thanks for the help
Brooke