Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Make your image Viewer with PictureBox control and ImageList control in VB.Net

Author: DevASP
Download Source Code : 339_Image_list.zip

In this simple article you will learn to work with Image List Control and able to make your image viewer.

Create New Project in VB.net. Drag a ImageList control from tool box and place on form and now drag and drop a button and a Picture Box on form1. Now go to properties of the image list and using property collection ADD picture which u want to show in your image viewer.

 

  • Now write code on form load event of the form

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

        Me.ImageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit

        PictureBox1.Image = ImageList1.Images.Item(count)

        PictureBox1.Height = Me.Height - 100

        PictureBox1.Width = Me.Width - 100

 

End Sub

 

  • Now write code on the button click event of button1

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

        count += 1

        If count + 1 > ImageList1.Images.Count Then

            count = 0

        End If

        PictureBox1.Image = ImageList1.Images.Item(count)

 

End Sub

 

  • Now write this code on mouse wheel event of the form1

Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseWheel

 

        count += 1

        If count + 1 > ImageList1.Images.Count Then

            count = 0

        End If

        PictureBox1.Image = ImageList1.Images.Item(count)

 

End Sub

 

  • Now write code on key Down Event of button1

 

Private Sub Button1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Button1.KeyDown

 

        count += 1

        If count + 1 > ImageList1.Images.Count Then

            count = 0

        End If

        PictureBox1.Image = ImageList1.Images.Item(count)

 

End Sub

 

Article Comments
No doubt it is very creative article but it is not working for C#.net.

Please send its C# version to me

Posted on 2/15/2007 7:17:17 AM by Avadhesh

Above code not work properly.
Display the image with blue color.

Posted on 10/12/2007 2:34:47 AM by JAGDISH

This code working vb.net But this is not working c# please send to c# version. ASAP.

Thanks &Regards
Rammohan

Posted on 2/5/2008 7:37:20 AM by Rammohan

this code not working properly it need the count value to be initialized. when we intialize the value it might not execute properly.

Posted on 9/25/2008 7:58:37 AM by samuel.g

yaa this code is nice.i whant to load images from external path...pls help me.

Posted on 3/13/2010 12:42:27 AM by Krish


the code is nice ...it realy help my :) thx but you forghet about a line of cone !!!

Dim Count As Integer = 0

u have to declare count !

Posted on 6/10/2010 9:56:55 AM by alcs00

hey,

nice script, it's really good, but i got one problem i hope you ppl can help me.

i got this line:

PictureBox1.Image = ImageList1.Images.Item(Count)

but it isn't working, it says:
InvalidArgument=Value of zero isn't valid as an index.

could anyone help me?
cya.


Posted on 6/24/2010 7:02:57 AM by Erobobo

thank you so match the code help me really thanks

Posted on 7/31/2010 10:58:52 AM by amal

This code is really helpful. thanks

Posted on 9/27/2010 3:35:41 AM by Salah uddin

i am also with Erobobo
same message come to me

Posted on 11/3/2010 2:29:23 AM by mohammed

when i save the record in vb.net form ,record is not save in data base ms access data base.but ms access feed data show in vb.net form in run time.

Posted on 11/6/2010 6:06:50 AM by vb.net

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Working with Key Board Events in VB.net Application.

Disclaimer - Privacy
© 2002-2017 DevASP.net