C# 視窗程式範例--Pictureboxpainting

要在 PictureBox 當中繪製圖形,必須改寫該 PictureBox 的 Paint() 事件函數,如下程式所示。

private void MyPictureBox_Paint(object sender, PaintEventArgs e)
{
  Graphics g = e.Graphics;
  using Pen selPen = new Pen(Color.White)
  {
    // do your drawing here
  }
  Image   img   =   Image.FromFile(@ "c:\abc.jpg "); 
  g.DrawImage(img,   0,   0,   100,   100); 
  // ...
}
	

文章來源:陳鍾誠 (2010年06月15日),(網頁標題) Pictureboxpainting,(網站標題) 免費電子書:C# 程式設計,2010年06月15日,取自 http://cs0.wikidot.com/pictureboxpainting ,網頁修改第 0 版。

arrow
arrow

    Johnson峰 發表在 痞客邦 留言(0) 人氣()