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;//自動伸展
}