Friday, July 30, 2010

Pgram to use picture box control to upload images in windows application.


Write a program to use picture box control to upload images in windows application.

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        public string path;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.ShowDialog();
            textBox1.Text = dlg.SafeFileName;
            pictureBox1.Image = Image.FromFile(textBox1.Text);
            path = dlg.FileName;
          
        }

        private void button2_Click(object sender, EventArgs e)
        {
            File.Copy(path, "D:\\" + textBox1.Text);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            menuStrip1.Items.Add("Copy");
        }

        private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            contextMenuStrip1.Items.Add("Copy");
        }

        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {

        }

        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }
    }
}

No comments:

Post a Comment