2010-11-20 54 views
0

如何使用一個事先知情同意我插入圖片框到mycodes?謝謝石化公司PictureBox的代碼

public KingPiece(Image image, ChessColor color) 
       : base(image, color) 
      { 


       ValidMoves = new Point(0, -1); // Up 1 
       ValidMoves = new Point(1, -1); // Up 1, Right 1 
       ValidMoves = new Point(1, 0);  // Right 1 
       ValidMoves = new Point(0, 1); 
       ValidMoves = new Point(-1, 0); 
       ValidMoves = new Point(-1, 1); 
       ValidMoves = new Point(1, 1); 
       ValidMoves = new Point(-1, -1); // Left 1, Up 1 


      } 
在此代碼

我想插入一個PIC是在picturebox.plz幫我

+0

你是什麼意思?你應該更詳細和ofc總是提供一段代碼,以便我們可以更有效地幫助你 – 2010-11-20 16:37:31

+0

我編輯我的問題 – Arash 2010-11-20 16:46:37

回答

2

PictureBox有一個屬性「圖像」。
在您的代碼中,您可以執行以下操作:
[Your-PictureBox-Name] .Image = Image.FromFile([your filename here]);

當然,您不僅可以從文件中獲取圖像,還可以從流,位圖甚至另一個圖片盒獲取圖像。

http://msdn.microsoft.com/en-us/library/system.drawing.image.aspx