Code Snippets

  

C# Source Code


Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 117,283 C# Programmers for FREE! Ask your question and get quick answers from experts. There are 2,284 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!


Submitted By: gbertoli3
Actions:
Rating:
Views: 85

Language: C#

Last Modified: August 7, 2008

Snippet


  1.         public void openBMP(String filename)
  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 = "";
  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.                 filename = openFileDialog.FileName;
  17.                 picBox.Image = Image.FromFile(filename);
  18.             }
  19.             else
  20.             {
  21.                 return;
  22.             }
  23.         }

Copy & Paste


Comments


There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month