What component to use

neversleep

Newcomer
Joined
Feb 21, 2003
Messages
6
Location
Sweden
Hi
I'm quite new to vb and also to this forum.

To the left in my program I want to display thumbnails in scrollable column that responds to mouseclicks. When a thumb is clicked some info will apper to the right in a textbox.

Since Im new to vb I have no idea what components to use and how. The picture data is read from a bytearray and I've succeded to read this to a picturebox and display it. I then created several pictureboxes and placed them in a Panel since I wanted the scrollable feature. Is this the right way to do it?

Would it be better to draw the thumbs directly in the panel, and is it possible?

Last question; how do I pic up wich thumb that was clicked?

Some syntax would help me to understand how this could be done. Hope someone can help me with one or all of the questions to lead me on to the right track :)
greets
 
Each picturebox should hold some information already, either in its Tag property (cheapo, old fashioned and dirty) ... or in custom properties.

Then all pictureboxes should get the identical eventhandler for click events attached to them.

In this eventhandler you'll receive a pointer to the sender - and thus the contents of the -tag or all other properties.


HTH
Heiko
 
The easiest way would certainly be to take advantage of the AutoScroll property of the Panel class, and place your pictureboxes all the way down the client area and below. You can use the events like Heiko said.

You certainly _could_ develop your own component and draw them yourself, but I don't think this would gain you much in this instance unless you wanted fancy things like mouseovers etc.
 
Thanks guys

I've never done any eventhandling on my own. Usualy in vb its only to ad the component in the designview and doubleclick it to enter what event to occur on click.
But now when i create my picturebox directly in code i have no idea how this should be done. Cant find any info on the internet either. Could you please give me a short intro?

in my code i create boxes in a loop, adds the thumb to the box and finaly add the picbox to a scrollable panel. where and how do i connect a eventhandler to the box?
Is the eventhandler some kinde of function that is designed to listen for clicks only from the pictureboxes?

pls do not laugh at my questions :)

this is how i create the pictures. what should i add to connect them to the identical eventhandler?

start loop
box = New PictureBox()
box.Image = test
box.Location = New System.Drawing.Point(0, 80)
pnlThumbs.Controls.Add(box)
end loop
 
Place a picturebox on your form.

DblClick it.

You'll be transported to a code segmet called sth like

PictureBox1_OnClick (....) handles .....

rename this to ....

AnyPictureBox_OnClick (....)

remove the "handles ..." part.

In this sub, you'll have access to the event's sender.

To connect this :

Visual Basic:
start loop
   box = New PictureBox()
   box.Image = test
   box.Tag = "Custom Tag"
   box.Location = New System.Drawing.Point(0, 80)
  
    AddHandler box.Click, AddressOf Me.AnyPictureBox_OnClick
                     
   pnlThumbs.Controls.Add(box)
end loop
 
Back
Top