RadhaKrishnaKiJaya
asked on
Create command buttons during run time
Hi Experts,
How can I create group of command buttons dynamically in a group box . For example I want to create 50 command buttons, 10 in each row and 5 in each column.
Thank you.
How can I create group of command buttons dynamically in a group box . For example I want to create 50 command buttons, 10 in each row and 5 in each column.
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I would use a FlowLayoutPanel instead of a GroupBox. It has being designed exactly for the purpose that you asked for, and its big advantage over the GroupBox is that it will automatically place the controls for your, either in line or in columns, with specifications about the distance between the controls and a few other things defined in its properties.
You use code similar to the one suggested by it_sauge, but can forget agout the whole x,y stuff. Simply add the buttons to the FlowLayoutPanel instead of the GroupBox.
You use code similar to the one suggested by it_sauge, but can forget agout the whole x,y stuff. Simply add the buttons to the FlowLayoutPanel instead of the GroupBox.
ASKER
Thank you for ur suggestion.
panel1.Add(btn)
btn.Name = "Save"
btn.Width = 120
btn.Height = 64
You need a panel control to add your button.