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;
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)
{
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;
pictureBox1.ImageLocation = picpath;
}
No comments:
Post a Comment