1.拖一个button一个textbox一个picturebox到面板,还有OpenFileDialog也要拖进去
2.相关代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace test3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openfile = new OpenFileDialog();
if (openfile.ShowDialog() == DialogResult.OK && (openFileDialog1.FileName != ""));
{
pictureBox1.ImageLocation = openfile.FileName;
textBox1.Text = openfile.FileName;
}
openfile.Dispose();
}
}
}