
Dynamic Control Creation At Runtime?
Gabriel,
Quote:
> Well... this code works for Panels:
> Button btn = new Button();
> btn.Name = "btnNew";
> btn.Text = "A New Button";
> btn.Location = new Point(20, 20);
> btn.Size = new Size(100, 30);
> btn.Visible = true;
> btn.Click += new EventHandler(OnNewButtonClick);
> panel2.Controls.Add(btn);
> But it doe not work if i add directly to the Control Array of the form
> it'se (form.Controls.Add(btn). The button will not show. Is there
> something special you have to do if you're creating the control on the
> form itself?
Shouldn't be. In fact, I've done it more than once. Could you post (or email
me) a small, compilable project that demonstrates the problem? I'd be happy
to take a look and see if I can help you out...
--
Tomas Restrepo