saaZ
saaZ

Reputation: 109

How to arrange buttons created in runtime in a GRID?

Is there any proper or simple way to arrange the button in a GRID?? I've buttons created in runtime.

Here is the format:

Button1      Button2     Button3

Button4      Button5     Button6

Button7      Button8     Button9

I am using C#.net with Visual Studio 2008.

Upvotes: 2

Views: 759

Answers (3)

basti
basti

Reputation: 2689

Just create a TableLayoutPanel before you create the Buttons and add the Buttons to the TableLayoutPanel, then add the TableLayoutPanel to the parent-control on which you wanted to show the Buttons.

There should even be a possibility to add the buttons to a specific cell of the TableLayoutPanel.

Upvotes: 1

Jon Skeet
Jon Skeet

Reputation: 1500575

You may want to look at using TableLayoutPanel... I'm sure there are other alternatives, but that's worked pretty well for me in the past. In particular, it gives you reasonable control over how the contents are sized - and resized. You need to think about how the space should be distributed between the buttons, particularly if they won't all be the same size.

Upvotes: 1

Nighil
Nighil

Reputation: 4129

in grid already you can make a format by columns and rows so there is no need for arrangement only you need to specify the column type as button

Upvotes: 0

Related Questions