icons cannot be displayed anylonger

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have bought a collection of professional icons in different sizes and
formats like png, bmp, ico, gif.

Now I have placed in one form the icons on navigation buttons within my form.
I don't know what happens but whatever I do, the icon is not visible so I
only see a gray button without any icon. If I enter a text for the button,
the text will be displayed (that means the compiler is realy compiling).

What else can be the reason that icons will not be visible? I tried both
ways: one via image list + image index, another way via direct pointing to
the icon file.
 
At a guess I would say that you are using EnableVisualStyles() without
DoEvents().
But even then, since Buttons with FlatStyle.System do not show an image you
will need to use a modified button control.

See the Button Class on my site, if the problem is due to using WindowsXP
Visual Styles.
http://www.dotnetrix.co.uk/buttons.html
 
Hello Mick,

your assumption was correct, you got it :-).
I have also studied your example with a new style on your homepage.
If I have already placed a button on a form, how can I apply now your new
style? Do I have to initiate a new button of type buttonEx (the class you
have defined) and copy all property settings over from my button to the new
one and disable the self-created button within the designer? Is there another
nice way to get it better?

Yours
 
The simplest thing to do is just open up the Designer Generated code and
edit the type.

e.g.
change
Me.Button1 = New System.Windows.Forms.Button
to
Me.Button1 = New ButtonEX

This way, since ButtonEx is inherited from button, it will retain all
settings. You'll then need to change FlatStyle to Standard
(AllowVisualStyles is defaulted to True).

You may also be interested in this alternative article on CodeProject:
http://www.codeproject.com/cs/miscctrl/MgXpImageButton.asp
There are limitations on this method in that the image can only be aligned
CenterLeft, CenterRight, TopCenter, BottomCenter or Center. There is,
however, an advantage to using this method. You can set different images for
each state of the button.
 
Back
Top