Wednesday, 21 May 2014

How to load image in picture Box from computer in window application



                                                                                                                                              Previous..
                                                                                                                                                    Next..
Here i will explain How to load image in picture Box from computer in window application.

Step(1): Form
In tutorial 4 i show you how to use picture box now here i will show you how to show picture and a button click from computer. So drag and down a picture box and a button.

Step(2): Form
Now double click on button and write this code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

using System.Text;
using System.IO;

namespace First_Csharp_app
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

private void LoadImage_click(object sender, EventArgs e)
{
OpenFileDialog openfile = new OpenFileDialog ();

openfile .filter = "JPG Files(* . jpg) | *.jpg | PNG Files(* . png) | * . png | All Files( * . *) | * . * " ;

if(openfile .ShowDialog() ==System.Window.Forms.DialogResult.OK)
{

string picpath openfile .FileName.ToString();
pictureBox1.ImageLocation = picpath;

}
}
}
}
Step(3): OutPut

Now run your application and select image from computer.
                                                                                                                                              Previous..
                                                                                                                                                    Next..

No comments:

Post a Comment

C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...