How to draw a pcitore in a control

G

Guest

i want to set a picture as a control's back ground by drawing it with
Graphics, but the Image class does not support the "FromFile" method in cf so
i can not load the pictrue from file. it there anyway to do that?
thx in advanced
 
C

Christian Resma Helle

Here's some sample of code of how to use draw using Graphics and
Bitmap

protected override void OnPaint(PaintEventArgs e) {
string file = string.Format("{0}\\image.jpg",

Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase));

Bitmap image = new Bitmap(file);

e.Graphics.DrawImage(image, this.ClientRectangle,
new Rectangle(0, 0, image.Width, image.Height),
GraphicsUnit.Pixel);
}
 
C

Christian Resma Helle

Here's a small code snippet for drawing a bitmap

[C# CODE]

protected override void OnPaint(PaintEventArgs e) {
string file = string.Format("{0}\\image.jpg",

Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);

Bitmap image = new Bitmap(file);

e.Graphics.DrawImage(image, this.ClientRectangle,
new Rectangle(0, 0, image.Width, image.Height),
GraphicsUnit.Pixel);
}


Regards,
Christian Resma Helle
http://christian-helle.blogspot.com
 

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