Adding a control from an external class
I am transferring most of my codes on a separate class and along with it is a code that adds a control during runtime. How can I add a control in my groupbox from another class?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Scott LyslePosted Aug 28, 2007, 11:48 PM
If your other class accepted the groupbox as an argument, you could allow your other class to add the control.
public static class OtherClass { public static void AddControl(GroupBox gbx) { Label lbl = new Label(); lbl.Text = "Five by Five"; lbl.Left = 10; lbl.Top = 15; gbx.Controls.Add(lbl); } }