Graphics: Draw an Icon
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
using System.IO;
public class Form1 : System.Windows.Forms.Form {
[STAThread]
static void Main() {
Application.Run(new Form1());
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) {
string p = "icon.ico";
Icon ic = new Icon(p);
this.Icon = ic; // Icon 1)
Graphics g = e.Graphics;
g.DrawIcon(ic, 0, 0); // Icon 2)
Image i = ic.ToBitmap();
g.DrawImage(i, 50, 0); // Icon 3)
g.Dispose();
}
}
Related examples in the same category