Align Anchor Panel BackgroundImage

G

Guest

I have a need to put an image on the background of a SplitterPanel. However,
I need it to appear in the bottom right corner of the panel instead of the
standard Centered/Tiled/Stretched found in the BackgroundImageLayout Property.

Is there an example of how to do that or could someone offer a suggestion?

Thanks
 
D

Dave Sexton

Hi,

You could try painting it yourself. Add an event handler for the splitter's
Paint event, grab its Graphics object from the EventArgs argument (e) and
use the DrawImage method.
 
G

Guest

Hi Dave,

Thanks for the response. I was able to draw the image where I wanted as you
specified. However, the crucial part is having it set as the backgroundimage
property.

The reason for this madness is b/c there is a third party tool I'm using
that has a transparency property. However, the only thing it is transparent
to is its container's backcolor, or backgroundimage.

Is there a way to override the PaintBackgroundImage event (if such one
exists) and insert my paint code that way?
 
D

Dave Sexton

Hi,

There's no override for painting only the background image, but there is a
protected OnPaintBackground method that you could try, although you'd have
to derive a control from SplitterPanel (if it's not sealed) and make sure
that it's not painting everything in Paint (i.e., make sure the
OnPaintBackground method is actually being invoked).

The behavior you mention is normal for WinForms on Windows XP, which just
emulates transparency on Controls (poorly). You may or may not be happy to
know that true transparency in WinForms seems to work just fine on Vista :)
 
G

Guest

Ok, that helped me get it.

I just extended the third party control and did an override on the
OnPaintBackground method.

After calling the base.OnPaintBackground, I was able to place my image on
the control.

..NET makes things like this easy to do.

It's just the process of figuring out HOW to do it that's hard.

Thanks for you help! :)
 

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