Greetings and salutations! I am having a real issue with the VB.NET
TreeView control. I need to display an image (a.k.a. logo, picture,
etc) from a file as the treenode object. I can not seem to find a way
to do this in .NET. I have tried the DrawImageUnscaled and thought
that was the way to go, but I was wrong. If anyone has any
suggestions, please help! The code I have currently follows:
Public Sub mTreeViewLoad(ByVal m_xmld As XmlDocument)
Try
trvMyList.BeginUpdate()
trvMyList.Nodes.Clear()
<!---code snipped for brevity --->
'loop through the xml and display each node
'all images are strored in an image list with indexes
'and each node text value contains the index to the image
fnRenderImage(trvMyList.Nodes)
trvMyList.SelectedNode = Nothing
trvMyList.EndUpdate()
Catch errorVariable As Exception
Console.WriteLine(errorVariable.Message)
End Try
End Sub
Private Function fnRenderImage(ByVal tnc As TreeNodeCollection)
Try
For Each tn As TreeNode In tnc
Dim x As Integer = tn.Bounds.X
Dim y As Integer = tn.Bounds.Y
If InStr(tn.Text, "_DRAW_IMAGE_") Then
Dim idxImage As Integer 'used to get the index
value from the image list
idxImage = tn.Text.Substring(12)
Dim img As Image =
lstViewerImages.Images(idxImage)
trvMyList.CreateGraphics.DrawImageUnscaled(img, x,
y)
tn.Text = ""
End If
fnRenderImage(tn.Nodes)
Next
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function 5 2475
Drag an ImageList onto the form, name it myImageList,
set the imagelist property of your Tree to myImageList
Add Images to the image list
To select an image for a Node.
tv.ImageIndex = 1 ' Or whatever the desired image index is
HTH
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"SeanT" <se******@hotmail.com> wrote in message
news:af**************************@posting.google.c om... Greetings and salutations! I am having a real issue with the VB.NET TreeView control. I need to display an image (a.k.a. logo, picture, etc) from a file as the treenode object. I can not seem to find a way to do this in .NET. I have tried the DrawImageUnscaled and thought that was the way to go, but I was wrong. If anyone has any suggestions, please help! The code I have currently follows:
Public Sub mTreeViewLoad(ByVal m_xmld As XmlDocument) Try trvMyList.BeginUpdate() trvMyList.Nodes.Clear() <!---code snipped for brevity ---> 'loop through the xml and display each node 'all images are strored in an image list with indexes 'and each node text value contains the index to the image
fnRenderImage(trvMyList.Nodes)
trvMyList.SelectedNode = Nothing trvMyList.EndUpdate() Catch errorVariable As Exception Console.WriteLine(errorVariable.Message) End Try End Sub
Private Function fnRenderImage(ByVal tnc As TreeNodeCollection) Try For Each tn As TreeNode In tnc Dim x As Integer = tn.Bounds.X Dim y As Integer = tn.Bounds.Y If InStr(tn.Text, "_DRAW_IMAGE_") Then Dim idxImage As Integer 'used to get the index value from the image list idxImage = tn.Text.Substring(12) Dim img As Image = lstViewerImages.Images(idxImage) trvMyList.CreateGraphics.DrawImageUnscaled(img, x, y) tn.Text = "" End If fnRenderImage(tn.Nodes) Next
Catch ex As Exception Throw New Exception(ex.Message) End Try End Function
An ImageList is not what I'm looking for. This creates Icon type
images next to the node values. I need the actual node to paint an
image, not text. Any suggestions? Any one?
"One Handed Man \( OHM - Terry Burns \)" <news.microsoft.com> wrote in message news:<uu**************@TK2MSFTNGP11.phx.gbl>... Drag an ImageList onto the form, name it myImageList, set the imagelist property of your Tree to myImageList Add Images to the image list
To select an image for a Node.
tv.ImageIndex = 1 ' Or whatever the desired image index is
HTH
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"SeanT" <se******@hotmail.com> wrote in message news:af**************************@posting.google.c om... Greetings and salutations! I am having a real issue with the VB.NET TreeView control. I need to display an image (a.k.a. logo, picture, etc) from a file as the treenode object. I can not seem to find a way to do this in .NET. I have tried the DrawImageUnscaled and thought that was the way to go, but I was wrong. If anyone has any suggestions, please help! The code I have currently follows:
Public Sub mTreeViewLoad(ByVal m_xmld As XmlDocument) Try trvMyList.BeginUpdate() trvMyList.Nodes.Clear() <!---code snipped for brevity ---> 'loop through the xml and display each node 'all images are strored in an image list with indexes 'and each node text value contains the index to the image
fnRenderImage(trvMyList.Nodes)
trvMyList.SelectedNode = Nothing trvMyList.EndUpdate() Catch errorVariable As Exception Console.WriteLine(errorVariable.Message) End Try End Sub
Private Function fnRenderImage(ByVal tnc As TreeNodeCollection) Try For Each tn As TreeNode In tnc Dim x As Integer = tn.Bounds.X Dim y As Integer = tn.Bounds.Y If InStr(tn.Text, "_DRAW_IMAGE_") Then Dim idxImage As Integer 'used to get the index value from the image list idxImage = tn.Text.Substring(12) Dim img As Image = lstViewerImages.Images(idxImage) trvMyList.CreateGraphics.DrawImageUnscaled(img, x, y) tn.Text = "" End If fnRenderImage(tn.Nodes) Next
Catch ex As Exception Throw New Exception(ex.Message) End Try End Function
Why can't you set the imagelist and when you ad nodes set the node text to
""?
"SeanT" <se******@hotmail.com> wrote in message
news:af**************************@posting.google.c om... An ImageList is not what I'm looking for. This creates Icon type images next to the node values. I need the actual node to paint an image, not text. Any suggestions? Any one?
"One Handed Man \( OHM - Terry Burns \)" <news.microsoft.com> wrote in
message news:<uu**************@TK2MSFTNGP11.phx.gbl>... Drag an ImageList onto the form, name it myImageList, set the imagelist property of your Tree to myImageList Add Images to the image list
To select an image for a Node.
tv.ImageIndex = 1 ' Or whatever the desired image index is
HTH
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"SeanT" <se******@hotmail.com> wrote in message news:af**************************@posting.google.c om... Greetings and salutations! I am having a real issue with the VB.NET TreeView control. I need to display an image (a.k.a. logo, picture, etc) from a file as the treenode object. I can not seem to find a way to do this in .NET. I have tried the DrawImageUnscaled and thought that was the way to go, but I was wrong. If anyone has any suggestions, please help! The code I have currently follows:
Public Sub mTreeViewLoad(ByVal m_xmld As XmlDocument) Try trvMyList.BeginUpdate() trvMyList.Nodes.Clear() <!---code snipped for brevity ---> 'loop through the xml and display each node 'all images are strored in an image list with indexes 'and each node text value contains the index to the image
fnRenderImage(trvMyList.Nodes)
trvMyList.SelectedNode = Nothing trvMyList.EndUpdate() Catch errorVariable As Exception Console.WriteLine(errorVariable.Message) End Try End Sub
Private Function fnRenderImage(ByVal tnc As TreeNodeCollection) Try For Each tn As TreeNode In tnc Dim x As Integer = tn.Bounds.X Dim y As Integer = tn.Bounds.Y If InStr(tn.Text, "_DRAW_IMAGE_") Then Dim idxImage As Integer 'used to get the index value from the image list idxImage = tn.Text.Substring(12) Dim img As Image = lstViewerImages.Images(idxImage) trvMyList.CreateGraphics.DrawImageUnscaled(img, x, y) tn.Text = "" End If fnRenderImage(tn.Nodes) Next
Catch ex As Exception Throw New Exception(ex.Message) End Try End Function
Perhaps I just don't understand you. I thought you wanted an image to appear
where the node is ?, what I told you will do this, where have I
misunderstood you ?
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"SeanT" <se******@hotmail.com> wrote in message
news:af**************************@posting.google.c om... An ImageList is not what I'm looking for. This creates Icon type images next to the node values. I need the actual node to paint an image, not text. Any suggestions? Any one?
"One Handed Man \( OHM - Terry Burns \)" <news.microsoft.com> wrote in
message news:<uu**************@TK2MSFTNGP11.phx.gbl>... Drag an ImageList onto the form, name it myImageList, set the imagelist property of your Tree to myImageList Add Images to the image list
To select an image for a Node.
tv.ImageIndex = 1 ' Or whatever the desired image index is
HTH
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"SeanT" <se******@hotmail.com> wrote in message news:af**************************@posting.google.c om... Greetings and salutations! I am having a real issue with the VB.NET TreeView control. I need to display an image (a.k.a. logo, picture, etc) from a file as the treenode object. I can not seem to find a way to do this in .NET. I have tried the DrawImageUnscaled and thought that was the way to go, but I was wrong. If anyone has any suggestions, please help! The code I have currently follows:
Public Sub mTreeViewLoad(ByVal m_xmld As XmlDocument) Try trvMyList.BeginUpdate() trvMyList.Nodes.Clear() <!---code snipped for brevity ---> 'loop through the xml and display each node 'all images are strored in an image list with indexes 'and each node text value contains the index to the image
fnRenderImage(trvMyList.Nodes)
trvMyList.SelectedNode = Nothing trvMyList.EndUpdate() Catch errorVariable As Exception Console.WriteLine(errorVariable.Message) End Try End Sub
Private Function fnRenderImage(ByVal tnc As TreeNodeCollection) Try For Each tn As TreeNode In tnc Dim x As Integer = tn.Bounds.X Dim y As Integer = tn.Bounds.Y If InStr(tn.Text, "_DRAW_IMAGE_") Then Dim idxImage As Integer 'used to get the index value from the image list idxImage = tn.Text.Substring(12) Dim img As Image = lstViewerImages.Images(idxImage) trvMyList.CreateGraphics.DrawImageUnscaled(img, x, y) tn.Text = "" End If fnRenderImage(tn.Nodes) Next
Catch ex As Exception Throw New Exception(ex.Message) End Try End Function
Where the text for a node appears, I need an image. The solution you
provided is great for icons next to the node, but not to replace the
node text itself with an image. So far, I have only found a third
party control (UltraTree) to do this. I would like to do this myself
and not depend on a 3rd party component.
Thanks,
Sean
"One Handed Man \( OHM - Terry Burns \)" <news.microsoft.com> wrote in message news:<#Q*************@TK2MSFTNGP10.phx.gbl>... Perhaps I just don't understand you. I thought you wanted an image to appear where the node is ?, what I told you will do this, where have I misunderstood you ?
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"SeanT" <se******@hotmail.com> wrote in message news:af**************************@posting.google.c om... An ImageList is not what I'm looking for. This creates Icon type images next to the node values. I need the actual node to paint an image, not text. Any suggestions? Any one?
"One Handed Man \( OHM - Terry Burns \)" <news.microsoft.com> wrote in message news:<uu**************@TK2MSFTNGP11.phx.gbl>... Drag an ImageList onto the form, name it myImageList, set the imagelist property of your Tree to myImageList Add Images to the image list
To select an image for a Node.
tv.ImageIndex = 1 ' Or whatever the desired image index is
HTH
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"SeanT" <se******@hotmail.com> wrote in message news:af**************************@posting.google.c om... > Greetings and salutations! I am having a real issue with the VB.NET > TreeView control. I need to display an image (a.k.a. logo, picture, > etc) from a file as the treenode object. I can not seem to find a way > to do this in .NET. I have tried the DrawImageUnscaled and thought > that was the way to go, but I was wrong. If anyone has any > suggestions, please help! The code I have currently follows: > > Public Sub mTreeViewLoad(ByVal m_xmld As XmlDocument) > Try > trvMyList.BeginUpdate() > trvMyList.Nodes.Clear() > <!---code snipped for brevity ---> > 'loop through the xml and display each node > 'all images are strored in an image list with indexes > 'and each node text value contains the index to the image > > fnRenderImage(trvMyList.Nodes) > > trvMyList.SelectedNode = Nothing > trvMyList.EndUpdate() > Catch errorVariable As Exception > Console.WriteLine(errorVariable.Message) > End Try > End Sub > > Private Function fnRenderImage(ByVal tnc As TreeNodeCollection) > Try > For Each tn As TreeNode In tnc > Dim x As Integer = tn.Bounds.X > Dim y As Integer = tn.Bounds.Y > If InStr(tn.Text, "_DRAW_IMAGE_") Then > Dim idxImage As Integer 'used to get the index > value from the image list > idxImage = tn.Text.Substring(12) > Dim img As Image = > lstViewerImages.Images(idxImage) > trvMyList.CreateGraphics.DrawImageUnscaled(img, x, > y) > tn.Text = "" > End If > fnRenderImage(tn.Nodes) > Next > > Catch ex As Exception > Throw New Exception(ex.Message) > End Try > End Function
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: naija naija |
last post by:
Hi All,
I'm using the TreView Web Control for my MENU.
And the Menu is populated from an XML file below.
I want a way in which i can manipulate the XML when i want to manage it
without having to...
|
by: markaelkins |
last post by:
Hi. I am trying to enter a variable in the treenodesrc of a treenode. I am
basically trying to send an ID variable into sql to return different records.
I've searched everywhere and cannot find the...
|
by: Bob |
last post by:
Hi,
I have a treeview which contains nodes of a class (classA) derived from
treenode.
These classA nodes may contain nodes of a class (ClassB) derived from
classA.
The form load populates a...
|
by: Mark Jerde |
last post by:
VS .NET 2003, Googling, msdn searching not successful.
I'm using the images of nodes of a TreeView to show the Pass/Fail results of
several tests. The tests are a little slow so I would like to...
|
by: Alan T |
last post by:
I am using VS 2005 and just wonder why I don't have this method?
|
by: WhiteWizard |
last post by:
Anyone out there today? Happy Thanksgiving!
I am writing a Window app that has a TreeView control. I am creating the
nodes dynamically from an XML file, and I have some icon images that I have...
|
by: divya1949 |
last post by:
Create a windows c# application which will
Read a xml file and populate nodes in the treeview.
1 On selection of treenode display the child nodes of that node in listview control
2. ...
|
by: AAaron123 |
last post by:
If you see this posted twice - sorry.
My news reader showed my first post as "No Longer Available"
I have the following in a .css file.
The treeNodes behave as if they were "a" elements.
...
|
by: Tom |
last post by:
I have your classic WinForm treeview that uses an image list with 2 images:
1. An open folder.
2. A closed folder.
The events that I have registered for are:
1. afterselect
2. afterexpand...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| | |