Adding Image Objects to Panel

P

Paul Engel

I'm new to this list...and hoping to be involved in a lot of great
dialogs with other programmers.

I've recently moved from VB6 to VB2008. I have read a lot of books,
so have a lot of theoretical knowledge, but would appreciate some
practical input on my current programming issue. The subject line
addresses one of the tasks I have.

The project: I have a database with thousands of records. Each record
references a "Document", which is a collection of pages. I have
written the Data Access Layer and created the associated Document
Class and Page Class. I also have a Documents Class to manage the
collection of documents represented by my database and a Pages Class
to manage the collection of pages w/in each document.

My task is to select pages from within the entire population of pages
from my database and display them as custom thumbnails if a
particular property of the Page object matches my criteria. (I hope
this is clear.) The custom aspect of the thumbnails is that I have to
be able to allow the user to enter a width and have the images size
accordingly...so I can't use a standard thumbnail control...unless
there's one out there that allows itself to be resized.

Here's what I am thinking of as a solution:
- Run through my database and instatiate my Document and Page objects
and the associated collections.
- Iterate through my Documents and associated Pages objects looking
for images that match my critera.
- Once I find matches, instantiate an ImageView Object (from a Class
I will write) and pass the associated Page object to it. The Image
Class constructor would instantiate an Image Control and a CheckBox
control that will be associated with this page. (I plan to use
controls that are already available in VB2008.)
- Create an array of all the ImageView objects. I want to do this
because I need to be able to sort all the matching images by one of
the properties, which will not necessarily have unique values. I
looked at a dictionary-type object for this, but can't guarantee
unique keys. The array seems to be the best approach, but suggestions
are welcome. An array sort is a pretty simple piece of code.
- Sort the array.
- Once the array is sorted, iterate through my array from index 0
through N, and add the associated Image Control to a panel on one of
my tabs.

Is this practical?

Any better ideas?

Anyone have any suggestions or sample code for dealing with placement
of the Image controls both when first being added to the panel or
when the form is resized? (The logic is that we add controls to a row
until there is no longer enough room in the panel for another, at
which time we begin forming a new row...and on and on until all the
image controls have been added.) Is there anything in VB2008 that
makes this easy, or do I just have to do the math and test to make
sure it works?

Finally, I'm not clear on how to marry the events of my Image control
and Checkbox control to their associated ImageView parent object?
When they are clicked, what is the best way handling that event in
order to change a property in the ImageView object or child Page
object to which it belongs. Are they related by a parent/child
relationship that can be referred to using a Me. or My. type of
handle?

I hope this is clear. Any help would be highly valued!

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top