-1

If building a form with multiple controls, let's say PictureBoxes, of equal square size.

The thing is that the number of controls is dynamic - there can be 2, 3, 4 or 6 controls.

And the goal is to automatically distribute the available form space between them. So they would remain square, but scale as large as possible considering other similar controls.

It it necessary to reinvent the wheel or a solution for this one is already available? Ideally, I'm looking for a container where you can just add the desired controls and they would be positioned automatically.

SharpAffair
  • 5,558
  • 13
  • 78
  • 158

1 Answers1

0

Is your form resizable? If so, what would you like to happen when the user re-sizes the form? Also, how would you like to position the elements? say you have 2 picture boxes, would you like them to be side by side, or one on top of the other? how would you like to position 3 picture boxes, and what about 4?

The first thing that came to my mind was using a TableLayoutPanel, but then I started to ask myself these questions, and tought that maybe a FlowLayoutPanel will be better for your needs.

Anyway, since you mentioned that the picture boxes should stay squares at all times, I think you will need to do the math in code to figure out how much space you need for each picture box, depending on your form size and number of elements.

Zohar Peled
  • 79,642
  • 10
  • 69
  • 121