By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Having a very odd problem with an imagelist?

P: n/a
Hey everyone. I have Visual Basic .NET 2003 and am trying to show images on
a treeview control. I have the imagelist on the form filled with images,
and have the ImageList property of the treeview control set to the imagelist
containing the images I want to be displayed next to each node.

It seems that no matter what I do there will be no images displayed next to
the nodes during runtime. I tried creating nodes during designtime using
the Nodes property, and the image appears next to the node in the designer
like it should, but when I run the app, there's no image visible, just a
blank space where the image is supposed to be followed by the node text.
Does this even when I add nodes at runtime, using code:

MyTreeview.Nodes.Add(New TreeNode("Node text", 0, 0))
0 is the index of the image in the imagelist that I want displayed.

I just noticed it does this with everything that uses the imagelist! The
toolbar, listview, treeview; everything behaves the same.

Also, this didn't always be a problem. It started acting this way when I
cut and pasted an imagelist control to a different form in one of my
projects. Its not a project-specific problem either, because I started a
new project and it does the same thing. I've tried restarting, running a
repair installation on VB.NET, nothing will fix it.

Even when I run the compiled app on another PC, same thing.

Anyone else having this weird problem? It's becoming very frustrating, and
would love to hear anyone's ideas. Thanks a lot.

Andrew
Nov 20 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi,

I had a similar problem with a toolbar a while ago. Look in the
Windows Form Designer generated code region. Make sure the imagelist is
created before the treeview.

Ken

-------------------------------

"Andrew Christiansen" <no-spam> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
Hey everyone. I have Visual Basic .NET 2003 and am trying to show images on a treeview control. I have the imagelist on the form filled with images,
and have the ImageList property of the treeview control set to the imagelist containing the images I want to be displayed next to each node.

It seems that no matter what I do there will be no images displayed next to the nodes during runtime. I tried creating nodes during designtime using
the Nodes property, and the image appears next to the node in the designer
like it should, but when I run the app, there's no image visible, just a
blank space where the image is supposed to be followed by the node text.
Does this even when I add nodes at runtime, using code:

MyTreeview.Nodes.Add(New TreeNode("Node text", 0, 0))
0 is the index of the image in the imagelist that I want displayed.

I just noticed it does this with everything that uses the imagelist! The
toolbar, listview, treeview; everything behaves the same.

Also, this didn't always be a problem. It started acting this way when I
cut and pasted an imagelist control to a different form in one of my
projects. Its not a project-specific problem either, because I started a
new project and it does the same thing. I've tried restarting, running a
repair installation on VB.NET, nothing will fix it.

Even when I run the compiled app on another PC, same thing.

Anyone else having this weird problem? It's becoming very frustrating, and would love to hear anyone's ideas. Thanks a lot.

Andrew

Nov 20 '05 #2

P: n/a
Tried that just now. I was excited because it sounded like it would solve
the problem, doesn't. I moved the block of code that sets the properties of
the imagelist:

'
ImageList1
'
Blah .........

Above where the listview is, and still no luck. Dang I'm getting very
frusterated I can't really do much of anything until I get this fixed, I've
been working on this problem for like 3 days now. Any other ideas? Is that
all you did to fix the toolbar problem you had? Thanks.

Andrew

"Andrew Christiansen" <no-spam> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
Hey everyone. I have Visual Basic .NET 2003 and am trying to show images on a treeview control. I have the imagelist on the form filled with images,
and have the ImageList property of the treeview control set to the imagelist containing the images I want to be displayed next to each node.

It seems that no matter what I do there will be no images displayed next to the nodes during runtime. I tried creating nodes during designtime using
the Nodes property, and the image appears next to the node in the designer
like it should, but when I run the app, there's no image visible, just a
blank space where the image is supposed to be followed by the node text.
Does this even when I add nodes at runtime, using code:

MyTreeview.Nodes.Add(New TreeNode("Node text", 0, 0))
0 is the index of the image in the imagelist that I want displayed.

I just noticed it does this with everything that uses the imagelist! The
toolbar, listview, treeview; everything behaves the same.

Also, this didn't always be a problem. It started acting this way when I
cut and pasted an imagelist control to a different form in one of my
projects. Its not a project-specific problem either, because I started a
new project and it does the same thing. I've tried restarting, running a
repair installation on VB.NET, nothing will fix it.

Even when I run the compiled app on another PC, same thing.

Anyone else having this weird problem? It's becoming very frustrating, and would love to hear anyone's ideas. Thanks a lot.

Andrew

Nov 20 '05 #3

P: n/a
I had the same problem when I used Application.EnableVisualStyles, my
existing toolbar icons didn't display their icons.
Another thing, the depth of the image may not be supported by your video
card, check the depth property of the image in the imagelist. Just some
extra suggestions.

"Andrew Christiansen" <no-spam> wrote in message
news:uo**************@TK2MSFTNGP10.phx.gbl...
Tried that just now. I was excited because it sounded like it would solve
the problem, doesn't. I moved the block of code that sets the properties of the imagelist:

'
ImageList1
'
Blah .........

Above where the listview is, and still no luck. Dang I'm getting very
frusterated I can't really do much of anything until I get this fixed, I've been working on this problem for like 3 days now. Any other ideas? Is that all you did to fix the toolbar problem you had? Thanks.

Andrew

"Andrew Christiansen" <no-spam> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
Hey everyone. I have Visual Basic .NET 2003 and am trying to show images
on
a treeview control. I have the imagelist on the form filled with

images, and have the ImageList property of the treeview control set to the

imagelist
containing the images I want to be displayed next to each node.

It seems that no matter what I do there will be no images displayed next

to
the nodes during runtime. I tried creating nodes during designtime using the Nodes property, and the image appears next to the node in the designer like it should, but when I run the app, there's no image visible, just a
blank space where the image is supposed to be followed by the node text.
Does this even when I add nodes at runtime, using code:

MyTreeview.Nodes.Add(New TreeNode("Node text", 0, 0))
0 is the index of the image in the imagelist that I want displayed.

I just noticed it does this with everything that uses the imagelist! The toolbar, listview, treeview; everything behaves the same.

Also, this didn't always be a problem. It started acting this way when I cut and pasted an imagelist control to a different form in one of my
projects. Its not a project-specific problem either, because I started a new project and it does the same thing. I've tried restarting, running a repair installation on VB.NET, nothing will fix it.

Even when I run the compiled app on another PC, same thing.

Anyone else having this weird problem? It's becoming very frustrating,

and
would love to hear anyone's ideas. Thanks a lot.

Andrew


Nov 20 '05 #4

P: n/a
Wow, I commented out the Application.EnableVisualStyles method that I was
calling in Sub Main() and, voulia, the image was there. Hmmm.... should I
call EnableVisualStyles elsewhere to keep it from doing that? Thanks!

Andrew

"Jared" <VB***********@email.com> wrote in message
news:vu************@corp.supernews.com...
I had the same problem when I used Application.EnableVisualStyles, my
existing toolbar icons didn't display their icons.
Another thing, the depth of the image may not be supported by your video
card, check the depth property of the image in the imagelist. Just some
extra suggestions.

"Andrew Christiansen" <no-spam> wrote in message
news:uo**************@TK2MSFTNGP10.phx.gbl...
Tried that just now. I was excited because it sounded like it would solve
the problem, doesn't. I moved the block of code that sets the properties
of
the imagelist:

'
ImageList1
'
Blah .........

Above where the listview is, and still no luck. Dang I'm getting very
frusterated I can't really do much of anything until I get this fixed, I've
been working on this problem for like 3 days now. Any other ideas? Is

that
all you did to fix the toolbar problem you had? Thanks.

Andrew

"Andrew Christiansen" <no-spam> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
Hey everyone. I have Visual Basic .NET 2003 and am trying to show

images
on
a treeview control. I have the imagelist on the form filled with

images, and have the ImageList property of the treeview control set to the

imagelist
containing the images I want to be displayed next to each node.

It seems that no matter what I do there will be no images displayed next to
the nodes during runtime. I tried creating nodes during designtime using the Nodes property, and the image appears next to the node in the designer like it should, but when I run the app, there's no image visible, just
a blank space where the image is supposed to be followed by the node text. Does this even when I add nodes at runtime, using code:

MyTreeview.Nodes.Add(New TreeNode("Node text", 0, 0))
0 is the index of the image in the imagelist that I want displayed.

I just noticed it does this with everything that uses the imagelist! The toolbar, listview, treeview; everything behaves the same.

Also, this didn't always be a problem. It started acting this way
when I cut and pasted an imagelist control to a different form in one of my
projects. Its not a project-specific problem either, because I
started
a new project and it does the same thing. I've tried restarting,
running
a repair installation on VB.NET, nothing will fix it.

Even when I run the compiled app on another PC, same thing.

Anyone else having this weird problem? It's becoming very

frustrating, and
would love to hear anyone's ideas. Thanks a lot.

Andrew



Nov 20 '05 #5

P: n/a
Figured it out! For everyone having this problem, call Application.DoEvents
right after calling EnableVisualStyles, it will enable the styles plus keep
the images intact. I have no idea why calling DoEvents fixes the problem,
but it does. The article I read that told me this said that there was
probably some message that gets filtered out upon calling EnableVisualStyles
that keeps the images from being visible, but when you call DoEvents the
message gets processed. Makes sense.

Thanks.

Andrew

"Andrew Christiansen" <no-spam> wrote in message
news:uv**************@TK2MSFTNGP12.phx.gbl...
Wow, I commented out the Application.EnableVisualStyles method that I was
calling in Sub Main() and, voulia, the image was there. Hmmm.... should I
call EnableVisualStyles elsewhere to keep it from doing that? Thanks!

Andrew

"Jared" <VB***********@email.com> wrote in message
news:vu************@corp.supernews.com...
I had the same problem when I used Application.EnableVisualStyles, my
existing toolbar icons didn't display their icons.
Another thing, the depth of the image may not be supported by your video
card, check the depth property of the image in the imagelist. Just some
extra suggestions.

"Andrew Christiansen" <no-spam> wrote in message
news:uo**************@TK2MSFTNGP10.phx.gbl...
Tried that just now. I was excited because it sounded like it would solve the problem, doesn't. I moved the block of code that sets the properties
of
the imagelist:

'
ImageList1
'
Blah .........

Above where the listview is, and still no luck. Dang I'm getting very
frusterated I can't really do much of anything until I get this fixed, I've
been working on this problem for like 3 days now. Any other ideas?
Is that
all you did to fix the toolbar problem you had? Thanks.

Andrew

"Andrew Christiansen" <no-spam> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
> Hey everyone. I have Visual Basic .NET 2003 and am trying to show

images
on
> a treeview control. I have the imagelist on the form filled with

images,
> and have the ImageList property of the treeview control set to the
imagelist
> containing the images I want to be displayed next to each node.
>
> It seems that no matter what I do there will be no images displayed

next to
> the nodes during runtime. I tried creating nodes during designtime

using
> the Nodes property, and the image appears next to the node in the

designer
> like it should, but when I run the app, there's no image visible,
just a > blank space where the image is supposed to be followed by the node text. > Does this even when I add nodes at runtime, using code:
>
> MyTreeview.Nodes.Add(New TreeNode("Node text", 0, 0))
> 0 is the index of the image in the imagelist that I want displayed.
>
> I just noticed it does this with everything that uses the imagelist!

The
> toolbar, listview, treeview; everything behaves the same.
>
> Also, this didn't always be a problem. It started acting this way when
I
> cut and pasted an imagelist control to a different form in one of my
> projects. Its not a project-specific problem either, because I

started
a
> new project and it does the same thing. I've tried restarting,

running
a
> repair installation on VB.NET, nothing will fix it.
>
> Even when I run the compiled app on another PC, same thing.
>
> Anyone else having this weird problem? It's becoming very

frustrating, and
> would love to hear anyone's ideas. Thanks a lot.
>
> Andrew
>
>



Nov 20 '05 #6

P: n/a
Cor
Hi Andrew,

That is greath this message because this is a workaround for what I thought
I have often seen in this newsgroup mentioned as something that was
imposible.

Cor
Figured it out! For everyone having this problem, call Application.DoEvents right after calling EnableVisualStyles, it will enable the styles plus keep the images intact. I have no idea why calling DoEvents fixes the problem,
but it does. The article I read that told me this said that there was
probably some message that gets filtered out upon calling EnableVisualStyles that keeps the images from being visible, but when you call DoEvents the
message gets processed. Makes sense.

Nov 20 '05 #7

P: n/a
Sorry, should have told you to use the DoEvents after EnbaleVisualStyles. I
thought the documentation said you should always do it. I must have started
using it when I first had the problem and just made it mandatory in my mind.
I guess I could have saved you a little time. Sorry about that.

Jared

"Cor" <no*@non.com> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
Hi Andrew,

That is greath this message because this is a workaround for what I thought I have often seen in this newsgroup mentioned as something that was
imposible.

Cor
Figured it out! For everyone having this problem, call

Application.DoEvents
right after calling EnableVisualStyles, it will enable the styles plus

keep
the images intact. I have no idea why calling DoEvents fixes the problem, but it does. The article I read that told me this said that there was
probably some message that gets filtered out upon calling

EnableVisualStyles
that keeps the images from being visible, but when you call DoEvents the
message gets processed. Makes sense.


Nov 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.