本例源代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Pictrue_View
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//打开文件夹时的对话框
private void btnSelectPicture_Click(object sender, EventArgs e)
{
if (ofdSelectPicture.ShowDialog() == DialogResult.OK)//判断其是否是满足条件的图片
{
//将图片显示在图片框中
picShowPicture.Image = Image.FromFile(ofdSelectPicture .FileName );
//显示图片名称和路径
this.Text = string.Concat("Picture View("+ofdSelectPicture.FileName +") ");
}
}
private void btnQuit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}