472,371 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

Change treeview image

Hi to all,

i have a treeview that i put some nodes in it with their repsective images.
If i try to change the image and set it to some other ImageList index,
nothing happens.

The code i use is:

private void ChangeServantStatus(string servant, ServantStatus status)
{
foreach (TreeNode n in treServants.Nodes[0].Nodes)
{
if (n.Text == servant)
{
n.ImageIndex = 4;
n.SelectedImageIndex = 4; break;
}
}
return;
}
I search ms support and i found the following article
"PRB: Windows Forms TreeView Control Does Not Handle State Image Lists in
Visual C# .NET"
that contains stuff like Interop Services, IntPtr, and SendMessage calls.

I do not think that there is no other way to handle this,
can anyone help me with this?
I just need a simple way to change an image in a TreeView.

thanks a lot for any help
anthonyb
Nov 15 '05 #1
1 16539
If you are trying to specify image indices in a DIFFERENT
ImageList, than you need to change the ImageList property
for the TreeView to the ImageList your trying to get the
images from.

ie.

private void ChangeServantStatus(string servant,
ServantStatus status)
{
// Change the TreeView's ImageList Property.
// If your TreeView is named treeView1, and the
// second ImageList is imageList2, then it would be...
treeView1.ImageList = imageList2;

foreach (TreeNode n in treServants.Nodes[0].Nodes)
{
if (n.Text == servant)
{
n.ImageIndex = 4;
n.SelectedImageIndex = 4; break;
}
}
return;
}
If that is infact what you are trying to do, I would
suggest putting all the images in the same ImageList and
just reference the index you want and not worry about
having to change the ImageList.

Keep in mind that in your sample code, it will only
change the first occurance of a TreeNode with the text
to "servant" (don't forget your quotes). If you wanted to
change all TreeNode's with that text, then remove the
break in the if statement.

Hope this helps,
Jacob

-----Original Message-----
Hi to all,

i have a treeview that i put some nodes in it with their repsective images.If i try to change the image and set it to some other ImageList index,nothing happens.

The code i use is:

private void ChangeServantStatus(string servant, ServantStatus status){
foreach (TreeNode n in treServants.Nodes[0].Nodes)
{
if (n.Text == servant)
{
n.ImageIndex = 4;
n.SelectedImageIndex = 4; break;
}
}
return;
}
I search ms support and i found the following article
"PRB: Windows Forms TreeView Control Does Not Handle State Image Lists inVisual C# .NET"
that contains stuff like Interop Services, IntPtr, and SendMessage calls.
I do not think that there is no other way to handle this,
can anyone help me with this?
I just need a simple way to change an image in a TreeView.
thanks a lot for any help
anthonyb

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nick Calladine | last post by:
Is this possible to ... I wish to get the value of a dropdown select but gets is indexable value (dont know if that is the right term) if that is possible (the position it assigned get assigned...
2
by: Mark Kamoski | last post by:
How can one change an image url at runtime? (Note, the image exists in a user control.) This is the image tag on the ascx... <asp:image id="TopBanner" runat="server"></asp:image> ....but...
3
by: Miguel Dias Moura | last post by:
Hello, i know how to hide a table according to a condition: <table runat="server" visible='<%# dataSetBibliotecas.FieldValue("Titulo", Container) <> "" %>'... Now I am trying to change the...
0
by: Jacek Francuz | last post by:
Hi! How can I change button image end send file to Client in one request? I try to change image in first step and I add onstartupscript: "Form1.submit()" and then in second step I send...
2
by: Miguel Dias Moura | last post by:
Hello, i know how to hide a table according to a condition: <table runat="server" visible='<%# dataSetBibliotecas.FieldValue("Titulo", Container) <> "" %>'... Now I am trying to change the...
0
by: Gavin | last post by:
Can anybody give me a code example of how to change an image size and resolution. I can upload a image file to a PostedFile. But what I need to do is change the size of that image and save it to my...
5
by: Laphan | last post by:
Hi All Just to confirm, is it true that you can't change the image of an <INPUT TYPE="IMAGE".... from within a CSS styelsheet? I know the standard command is SRC="....", but there doesn't seem...
3
by: vartana | last post by:
I will be getting the background url dynamically using ajax and html. I have set an id=boxFooter_002 to my div and have ...
5
by: danmoran | last post by:
I would like to change the image on animageButton as this is clicked by the user. when the master page is loaded it shows the btnHome.ImageUrl = "~/images/home.jpg"; But when the user clicks on...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.