Display an image into windows forms

前端 未结 4 1803
借酒劲吻你
借酒劲吻你 2021-02-07 11:51

I wanted to display an image to the windows forms, but i already did this and the image did not come out.

Where did I go wrong?

Here is the code:



        
4条回答
  •  忘了有多久
    2021-02-07 12:27

    Here (http://www.dotnetperls.com/picturebox) there 3 ways to do this:

    • Like you are doing.
    • Using ImageLocation property of the PictureBox like:

      private void Form1_Load(object sender, EventArgs e)
      {
          PictureBox pb1 = new PictureBox();            
          pb1.ImageLocation = "../SamuderaJayaMotor.png";
          pb1.SizeMode = PictureBoxSizeMode.AutoSize;
      }
      
    • Using an image from the web like:

      private void Form1_Load(object sender, EventArgs e)
      {
          PictureBox pb1 = new PictureBox();            
          pb1.ImageLocation = "http://www.dotnetperls.com/favicon.ico";
          pb1.SizeMode = PictureBoxSizeMode.AutoSize;
      }
      

    And please, be sure that "../SamuderaJayaMotor.png" is the correct path of the image that you are using.

提交回复
热议问题