1.界面上拖个.pictureBox(pictureBox1)
//上传点击按钮
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog fileDialog = new OpenFileDialog();
DialogResult result = fileDialog.ShowDialog();
if (result == DialogResult.OK)
{
this.pictureBox1.Image = Image.FromFile(fileDialog.FileName);
}
}
//清楚图片按钮
private void button2_Click(object sender, EventArgs e)
{
this.pictureBox1.Image = null;
}
C#--程序背景图片设置
public Form1()
{
InitializeComponent();
this.pictureBox1.BackgroundImage = Image.FromFile(@"C:UsersadminDesktoplogo.png");
this.BackgroundImageLayout = ImageLayout.Stretch;//自动伸展
}