Graphics.DrawIcon Not Working

N

neemarr

Im trying to create a custom control that has a background and a few
icons drawn in it.
The background draws but the icons don't.

In my override OnPaint method I have:

e.Graphics.FillRectangle(new SolidBrush(CustomColors.CarouselBG),
this.ClientRectangle);

for(int i...)
{
e.graphics.DrawIcon(this.m_Icon, anXInsideClientRect,
aYInsideClientRect);
}

the icon is 32x32 icon and the client rectangle is much larger and it
can contain several icons of that size.
even if I don't do the FillRectangle, I still won't see my icons. The
bounds for the control were set at some point before that, and I am
positive the points I'm providing the DrawIcon are within the client
rectangle. I can give more details if you would like. Thanks
 
N

neemarr

Im trying to create a custom control that has a background and a few
icons drawn in it.
The background draws but the icons don't.

In my override OnPaint method I have:

e.Graphics.FillRectangle(new SolidBrush(CustomColors.CarouselBG),
this.ClientRectangle);

for(int i...)
{
    e.graphics.DrawIcon(this.m_Icon, anXInsideClientRect,
aYInsideClientRect);

}

the icon is 32x32 icon and the client rectangle is much larger and it
can contain several icons of that size.
even if I don't do the FillRectangle, I still won't see my icons. The
bounds for the control were set at some point before that, and I am
positive the points I'm providing the DrawIcon are within the client
rectangle. I can give more details if you would like. Thanks


I did not know the fact that the X and Y you give to the DrawIcon or
any Graphics.draw method have to be in relation to the control not the
container which was a form, now that I think about it that makes
perfect sense. Sometimes I feel like a dumbass.
 
S

Simon Hart [MVP]

The only thing I can think of to check if you're sure you are drawing within
the bounds of the client rectangle is to check the icon array is definately
valid. What colour depth icons are you using? Can you show us the code which
creates the m_icon array?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top