Skip to content

Instantly share code, notes, and snippets.

@nhoxbypass
Created December 11, 2017 14:20
Show Gist options
  • Save nhoxbypass/79c5ee02eccf86a29704dd4512c21d99 to your computer and use it in GitHub Desktop.
Save nhoxbypass/79c5ee02eccf86a29704dd4512c21d99 to your computer and use it in GitHub Desktop.
private void Form1_Load(object sender, EventArgs e)
{
// Lấy file ảnh từ ổ cứng
// File ảnh phải có trong thư mục debug của solution
// Nếu không chương trình sẽ bị crash vì không tìm thấy file
// Có thể để đường dẫn tuyệt đối đến file ảnh
//(bao gồm cả ổ đĩa, thư mục,...)
Image image = Image.FromFile("BeigeMonitor1.png");
// Thiết lập thuộc tính của PictureBox
// Gán ảnh đã lấy vào PictureBox
pictureBox1.Image = image;
pictureBox1.Height = image.Height;
pictureBox1.Width = image.Width;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment