|
-
Feb 21st, 2000, 02:04 AM
#1
Thread Starter
Lively Member
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
-
Feb 21st, 2000, 02:27 AM
#2
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:
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
This will add a Parent and a Child nodes, then it will make the Child node Bold.
------------------
Serge
Senior Programmer Analyst
[email protected]
[email protected]
ICQ#: 51055819
[This message has been edited by Serge (edited 02-21-2000).]
-
Feb 21st, 2000, 03:28 AM
#3
Thread Starter
Lively Member
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.
[This message has been edited by BHostmeyer (edited 02-21-2000).]
-
Feb 21st, 2000, 05:45 AM
#4
Thread Starter
Lively Member
Is there anyway to change the line color as well.
maybe with the TVM_SETTEXTCOLOR ?
-
Feb 21st, 2000, 06:11 AM
#5
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
-
Feb 21st, 2000, 06:14 AM
#6
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
-
Feb 21st, 2000, 06:20 AM
#7
Thread Starter
Lively Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|