how to apply image as background to the panel control
I would like to place one image to panel control in windows mobile开发者_开发知识库 application,but in properties to that control we have only backgroundcolor.what to do in this type of situation?
I am using VS 2008,windows mobile 6 professional
Create a new class that inherits from Panel and override OnPaintBackground.
class MyPanel : Panel
{
private Image m_image;
public Image BackgroundImage
{
get { return m_image; }
set
{
if (m_image != null) m_image.Dispose();
m_image = value;
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{
if (BackgroundImage == null)
{
base.OnPaintBackground(e);
}
else
{
e.Graphics.DrawImage(BackgroundImage, 0, 0);
}
}
}
精彩评论