Click here to Skip to main content
15,903,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

Can I design controls at runtime, resizing and dropping controls at runtime. I have restaurant application, there is a form where I have to design tables (buttons).

Best regards,
Bujar Akiki
Posted

Hi Bujar,

yes, you can create your controls dynamically and make use of the PropertyGrid to make changes to the appearance of that control.

Hope this is some help.

Modified:

This is what I found out:
I created a form that contained a PropertyGrid a Panel and a Button. The buttons event handler creates a new button button = new Button() and adds that to the panel Panel1.Controls.Add(button).
The property grid is hooked to the button via PropertyGrid1.ObjectSelected = button and presto: A button was dynamically created and can be manipulated via the property grid.

Ain't that .NET framework neat ;)

End Modification:

Cheers


Manfred
 
Share this answer
 
v5
C#
private void AddControls_Click(object sender, EventArgs e)
       {
           Button newButton = new Button { Text = "New Button" };
           CheckBox newCheckBox = new CheckBox { Text = "New CheckBox", ThreeState = true };
           List<Control> lst = new List<Control>();
           lst.Add(newButton);
           lst.Add(newCheckBox);
           this.Controls.AddRange(lst.ToArray());
       }
 
Share this answer
 

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