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
Posts: 1267
Joined: Sat Apr 16, 2011 7:49 am
Location: Montreal, Canada
Contact:

How to Image to a PictureBox

#2275

Post by Superl » Sat Dec 19, 2015 5:47 am

Image to a PictureBox Introduction:
Loading a Bitmap Image into a PictureBox from an OpenFileDialog.
  1. public void openBMP()
  2. {
  3.        //Declare the OpenFileDialog as a new OpenFileDialog.
  4.        OpenFileDialog openFileDialog = new OpenFileDialog();
  5.        //Declare the PictureBox as a new PictureBox
  6.        PictureBox picBox = new PictureBox();
  7.        //Set the openFileDialog's Filter.
  8.        openFileDialog.Filter = "Bitmap Image|*.bmp|All Files|*.*";
  9.        //Set the openFileDialog's FileName to nothing.
  10.        openFileDialog.FileName = string.Empty;
  11.        //Show the openFileDialog
  12.        if (openFileDialog.ShowDialog(this) == DialogResult.OK)
  13.        {
  14.               //To do code if the Open button was pressed
  15.               //Use something like:              
  16.               picBox.Image = Image.FromFile(openFileDialog.FileName);
  17.        }
  18.        else
  19.        {
  20.               return;
  21.        }
  22. }


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

Have a nice day :103:

Post Reply

Return to “Coding Forum”

Who is online

Users browsing this forum: No registered users and 2 guests