How to Image to a PictureBox

Will be posting article on how to create simple application, with full working code in C#
And welcome to anyone who want to post their own article
Post Reply
User avatar

Topic author
Superl
Site Admin
Site Admin
Man of action
Man of action
Posts: 1331
Joined: Sat Apr 16, 2011 7:49 am
12
Location: Montreal, Canada
Contact:

How to Image to a PictureBox

#2275

Post by Superl »

Image to a PictureBox Introduction:
Loading a Bitmap Image into a PictureBox from an OpenFileDialog.

Code: Select all

public void openBMP()
{
//Declare the OpenFileDialog as a new OpenFileDialog.
OpenFileDialog openFileDialog = new OpenFileDialog();
//Declare the PictureBox as a new PictureBox
PictureBox picBox = new PictureBox();
//Set the openFileDialog's Filter.
openFileDialog.Filter = "Bitmap Image|*.bmp|All Files|*.*";
//Set the openFileDialog's FileName to nothing.
openFileDialog.FileName = string.Empty;
//Show the openFileDialog
if (openFileDialog.ShowDialog(this) == DialogResult.OK)
{
//To do code if the Open button was pressed
//Use something like:
picBox.Image = Image.FromFile(openFileDialog.FileName);
}
else
{
return;
}
}


Come and say hello in here
Any donation will help click here please.

Have a nice day :103:
Post Reply

Return to “Coding Forum”