-
March 31st, 2014, 02:17 PM
#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!
-
April 3rd, 2014, 10:58 AM
#2
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
}
-
April 8th, 2014, 09:48 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|