how make a button to open an image?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: how make a button to open an image?

  1. #1
    Join Date
    Mar 2014
    Posts
    1

    how make a button to open an image?

    I want to learn C# and I've put a simple button.. I want it to open an image when the user clicks the button. I don't know how to do that. Can you give me some advice please? I'm new here

    Code:
    namespace WpfApplication3
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, RoutedEventArgs e)
            {
    
            }
        }
    }
    Thanks in advance!

  2. #2
    Join Date
    May 2002
    Posts
    487

    Re: how make a button to open an image?

    Check out OpenFileDialog class and PictureBox control:


    Code:
    OpenFileDialog ofd = new OpenFileDialog();
    ofd.InitialDirectory = ".";
    ofd.Title = "Select Document Image";
    ofd.DefaultExt = "tif";
    ofd.Filter = "All Image Files (.tif;.bmp;.png;.gif;.jpg;.jpeg;.jfif)|*.tif;*.bmp;*.png;*.gif;*.jpg;*.jpeg;*.jfif|TIFF Images (.tif)|*.tif|All Files (*.*)|*.*";
    
    DialogResult dr = ofd.ShowDialog();
    if (dr == DialogResult.OK)
    {
            // display image
    }

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,091

    Re: how make a button to open an image?

    You could also have a look into the Process class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center