How to draw ICON on VS.NET 2003

G

Guest

Hi, how are you

I want to draw a ICON on My Panel?

How to do it?

In C++; We can use CDC, and draw?

public class PictureField : Panel
{
private bool isEditable = false;
public PictureField(bool editable)
{
this.Enabled = false;
this.Size.Height = 20;
this.Size.Width = 20;
isEditable = editable;
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);

}

}

if I can not draw on Panel, What is the best way to draw a pic to control?

Thanks
 
T

Tim Wilson

You can draw an image onto the control using the Graphics object that is
passed through the PaintEventArgs object to the OnPaint override. In
particular, look at the DrawIcon and DrawImage methods, whichever is more
appropiate in your situation.

protected override void OnPaint (PaintEventArgs e)
{
//e.Graphics.DrawImage(...);
base.OnPaint(e);
}
 

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