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:\Users\admin\Desktop\logo.png");
this.BackgroundImageLayout = ImageLayout.Stretch;//自动伸展
}

posted on 2018-07-10 14:38  红磨坊后的白桦树  阅读(178)  评论(0编辑  收藏  举报