How to draw ICON on VS.NET 2003

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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);
}
 
Back
Top