Beginner question: How do I position controls in a GroupBox?

E

Enkidu

I'm trying to add TextBoxes in a square 'array' into a GroupBox. It
looks like I have to, for each TextBox, get the size of the GroupBox,
calculate position of each TextBox, set the Location of the TextBox to a
new Location object with the calculated coordinates and the TextBox
should then be located in the correct position. I'd much rather say, for
example, left gap equals x%, top gap = y%, draw the TextBox, dimensions
a% by b%, move right z%, draw the next TextBox and so on.

What I'm aiming for is a square of TextBoxes which form a playing grid,
much like a chessboard.

I guess the answer to the question is "I wouldn't do it that way, and I
suggest you do it this way...." sort of thing.

Any help would be appreciated.

Cheers,

Cliff
 
B

Bram

Hi Enkidu,

The control you are looking for is the TableLayoutPanel. This .NET 2.0
control allows you to do exactly what you want to do.

Cheers,
Bram
 
P

Peter Duniho

The control you are looking for is the TableLayoutPanel. This .NET 2.0
control allows you to do exactly what you want to do.

Alternatively, depending on the exact behavior desired, the
FlowLayoutPanel may be preferable.

In either case, just put the panel inside the GroupBox, then add your
TextBox instances to the ...LayoutPanel programmatically as necessary.

Pete
 
E

Enkidu

Peter said:
Alternatively, depending on the exact behavior desired, the
FlowLayoutPanel may be preferable.

In either case, just put the panel inside the GroupBox, then add your
TextBox instances to the ...LayoutPanel programmatically as necessary.
Thanks guys!

Cheers,

Cliff
 

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