using pic in picturebox in code
how can i use a pic i inserted in picturebox into mycodes?thanks
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开发者_开发百科
}
in this code i want to insert a pic that is in picturebox.plz help me
PictureBox has a property "Image".
In your code you can just do the following:
[Your-PictureBox-Name].Image = Image.FromFile([your filename here]);
of course you can get your image not just from a file but also from a stream, a bitmap or even another picturebox.
http://msdn.microsoft.com/en-us/library/system.drawing.image.aspx
精彩评论