Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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

.nerd
  • *Gurus*
Posted

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.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

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

Posted

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 :

 

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

.nerd

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...