|
-
Jan 28th, 2003, 09:30 AM
#1
Thread Starter
Hyperactive Member
Adding an image to a parent node in a dynamic Treeview *[RESOLVED]*
What's the correct syntax for adding an image to parent nodes in a Treeview? I have the images ready in an image list, but i'm stuck as to how to add the image at runtime as the list is generated dynamically everytime the program's ran.
Thanks.
Last edited by RealNickyDude; Jan 30th, 2003 at 06:33 PM.
-
Jan 28th, 2003, 01:05 PM
#2
You can pass the index of the image into the constructor of the treenode.
dim nod as New TreeNode("MyText",ImageIndex, SelectedImageIndex)
If you want the image of the node to be the same when it is selected then just pass the same index twice.
-
Jan 28th, 2003, 01:29 PM
#3
I have a lot fo the client done on the code storage/sharing app I've been working on. If you want I'll post the client code which has some things like loading a treeview dynamically. A lot of the other stuff probably wont help because it is related to the sharing bit, but there could be some stuff that you want to use. Also the loading the treeview currently works off of loading a datatable which I need to change to work with a class instead. So if you want it hten let me know and i'll post it.
-
Jan 28th, 2003, 01:31 PM
#4
Thread Starter
Hyperactive Member
Yes please
-
Jan 28th, 2003, 02:50 PM
#5
Here you go. Its the IShareClient. There is still a lot of work that needs to be done to it but the cosmetic stuff is all you really need and that should be done for the most part.
Well it seems the file is too big...I'll post a link in a sec
-
Jan 28th, 2003, 04:07 PM
#6
Well it seems my server has decided to be problematic today so it'll have to wait until I get home. Or if you want me to email it to you then just give me your email address.
-
Jan 28th, 2003, 04:14 PM
#7
Thread Starter
Hyperactive Member
-
Jan 30th, 2003, 09:44 AM
#8
Thread Starter
Hyperactive Member
Very impressive! And very complicated!! (for me anyway) I still don't know how to add an image to the parent nodes!
here's the code i'm using to create the treeview:
VB Code:
Private Sub RefreshList()
Try
Dim topics() As String = Directory.GetDirectories("code\")
Dim str As String
TreeView1.ImageList = ImageList1
For Each str In topics
Dim dir As New DirectoryInfo(str)
Dim fi() As FileInfo = dir.GetFiles("*.rtf")
Dim node As New TreeNode(str.Substring(str.IndexOf("\") + 1))
TreeView1.Nodes.Add(node)
Dim f As FileInfo
For Each f In fi
node.Nodes.Add(f.Name.Remove(f.Name.IndexOf("."), 4))
Next
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
how would I add an image (different for each parent) from an imagelist?
-
Jan 30th, 2003, 11:09 AM
#9
On this line:
VB Code:
Dim node As New TreeNode(str.Substring(str.IndexOf("\") + 1))
Just add the imageindex from the ImageList to the end
VB Code:
Dim node As New TreeNode(str.Substring(str.IndexOf("\") + 1),ImageListIndex,ImageListIndex)
Then whatever you want to use to change that number you do that first.
-
Jan 30th, 2003, 06:33 PM
#10
Thread Starter
Hyperactive Member
Thanks yet again Edneeis
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
|