Click here to Skip to main content
15,742,477 members
Please Sign up or sign in to vote.
1.00/5 (5 votes)
See more:
I have a form with a user control inside that has images loaded from reading xml file. I want to know if there is a possibility that user control may expand when the loaded images are consuming more spaces inside the user control that it exceed to the size of the form? Is there a code for making the user control expand and can be navigated inside the form? Help me, Thanks :)

Please don't post irrelevant comments.
OriginalGriff 23-Dec-10 4:33am    
"Please don't post irrelevant comments."
I'm sorry, could you explain this part of your question?
yummy02 23-Dec-10 6:17am    
@OriginalGriff: Some user are not posting relevant comments and suggestions but they rather intrigue the people asking not considering if the user's ability to think logically. That's it. :)

1 solution

hi yummy,

You remember the example code I showed you for creating the picture boxes? I used a panel as container control - and used AutoScroll.
So Scrolling is the first solution that comes to my mind.
Maybe you can also resize the container (Panel) when adding more pictures. Just Meassure the sizes, sum them up and calculate and assign the new size of the container, then let the user scroll.

As I said. There is another solution involving Paint and Resize event handling. So you have the option to completly control the layout and drawing of your control (but this can be quite complicated).

Before fiddling any longer with your problem, maybe you tell us(me) just what you really want to do?

As far as I remember:

* You read Image-Paths from xml
* You create a Container-Control for all images
* You add the images to the container and layout them

But what you want the user do with the pictures. Is this some kind of thumbnail control, viewer or a picker or what? I guess you can find a lot of good examples for all those kinds of "Picture-Controls"...

Good luck!
Share this answer
yummy02 24-Dec-10 7:21am    
Thanks johannesnestler. Actually, what I really want to do is to create a user control. When the form loads, the user control loads also (dragging user control to form I guess is the appropiate), then the user control reads the xml file. In xml file, there's name, x, y and path. I'll create an instances of label and picture box. In label, the name childnode from xml will be loaded. 'x and y' childnodes sets the location of picture box and label then path is the location of picture that will be loaded in pbox. The user control loads the content of xml file. After that, I have to create (draw) lines that connects each pbox. Thank you so much johannesnestler, God bless and Merry Christmas. :)
johannesnestler 25-Dec-10 6:47am    
Marry Christmas Yummy,

If you store the position of the sub-controls (Labels and PictureBoxes) and draw lines between them, then I'd definitly would go for the OwnerDrawn solution.

1. Load the xml data in the same way
2. In the UserControl store a list of the XML-Information objects (PictureWithPositionAndLabel)
- create a class for this infos.
3. In the Resize event handler of the UserControl you can then layout your objects (recalculate position, scroll size etc.)
4. In the Paint event handler of the UserControl use DrawImage, DrawLine etc. to draw the picture the label and the lines.
5. Add other eventhandlers to your control for clicking and dragging the pictures, lines etc. - I assume you want the user to drag the pictures arround.

I hope you find a nice solution for your problem!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900