在WinForm中有一个Button和一个PictureBox,通过点击按钮打开对话框向PictureBox中添加图片
解决方案 »
- 怎么把脚本加密~求高人指点
- 小白问题,用input和select仿ComboBox功能,获取不到input中输入的值
- c#如何重绘窗口
- 肯求:c# .net 打印表格的类 ,谢谢~` 100分~~~
- 有关线程的小问题
- 主菜单、子菜单传值问题
- 在一个窗体中输入修改内容,然后存到另一个窗口的 dataGridView当中
- 怎么样在C/S模式的DataGrid控件中的某一列加上ComboBox控件或者是一个下拉列表的控件啊?
- 怎样把几个dataset和在一起?
- 求《Practical Software Engineering: Analysis and Design for the .NET Platform》电子版
- 如何对相同的文件后缀名排序?
- nunit和VS中自带的单元测试是怎么回事?
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
openFileDialog.Filter = "Text Files (*.jpg)|*.txt|All Files (*.*)|*.*";
if (openFileDialog.ShowDialog(this) == DialogResult.OK)
{
string FileName = openFileDialog.FileName;
pictureBox1.ImageLocation = FileName;
}
{
OpenFileDialog openFileDialog = new OpenFileDialog();
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
this.pictureBox1.Image = Image.FromFile(openFileDialog .FileName );
}
this.pictureBox1.ImageLocation=openFileDialog .FileName ;
}
private void btnLoadpicture_Click(object sender,EventArgs s)
{
pictureBox1.LoadAsync("路径"); //路径中/要用//代替。这点不解释撒
}
private void btnLoadpicture_Click(object sender,EventArgs s)
{
pictureBox1.CancelAsync();//取消
}
{
OpenFileDialog openFileDialog = new OpenFileDialog();
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
this.pictureBox1.Image = Image.FromFile(openFileDialog .FileName );
}
this.pictureBox1.ImageLocation=openFileDialog .FileName ;
}
这样就行