Load a bitmap image into Windows Forms using open file dialog

后端 未结 8 736
梦毁少年i
梦毁少年i 2020-12-10 02:21

I need to open the bitmap image in the window form using open file dialog (I will load it from drive). The image should fit in the picture box.

Here is the code I t

8条回答
  •  抹茶落季
    2020-12-10 02:50

    You can try the following:

    private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog fDialog = new OpenFileDialog();
            fDialog.Title = "Select file to be upload";
            fDialog.Filter = "All Files|*.*";
            //  fDialog.Filter = "PDF Files|*.pdf";
            if (fDialog.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = fDialog.FileName.ToString();
            }
        }
    

提交回复
热议问题