Friday 13 April 2012

PictureBox in VB.NET/C# || How to display image in windows forms || How to add image in windows form

Hi Friends, in this article I will explain about how to display image in windows forms.         
 First take one web form, 

 
File ----> Add New Project ----> Give the name Aspdotnet-kishore ----> OK
Drag and Drop PictureBox into the form from the ToolBox and double click on the form then Form1_Load event is create like below.
Private Sub Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Then write the following code in the Form1_Load
 VB.NET Code:
 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim img As Image = Image.FromFile("C:\new-star.gif")
        PictureBox1.Image = img
        PictureBox1.Width = 5000
        PictureBox1.Height = img.Width
       'PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

        'PictureBox1.Cursor = System.Windows.Forms.Cursors.Hand
    End Sub

C# Code:


private void Form1_Load(System.Object sender, System.EventArgs e)
{
     Image img = Image.FromFile("C:\\new-star.gif");
     PictureBox1.Image = img;
     PictureBox1.Width = 5000;
     PictureBox1.Height = img.Width;
}
  
And press Enter.Then the output is like below.
"If you like my blog or articles, you can appreciate by leaving your comments or Liking my Facebook pageAspdotnet-kishore, following on Google+ Aspdotnet-Kishore, Twitter  on AspdotnetKishore, Linked in Aspdotnet-Kishore, stumbling my posts on stumble upon and subscribing on  RSSfeed Aspdotnet-Kishore for free updates directly to your Email inbox . Watch my blog  for more articles." 
 
 
 
 
 
 
 

1 comment:

© 2012-2018 Aspdotnet-Kishore.blogspot.com. All Rights Reserved.
The content is copyrighted to Kishore and may not be reproduced on other websites without permission from the owner.