Dynamic Contorls & Classes

  • Thread starter Thread starter MikeY
  • Start date Start date
M

MikeY

Hiya All,

I'm coding in C#, & making a windows application. I am trying to figure out
how to put my dynamic control code in a seperate class (say ie
ButtonClass.cs) so that I can re-use the code with in multiple forms
(ie.frmOne, frmTwo). Being a newbie, I'm not sure if I should try my hand at
Interface class or what to do here.

Could anyone out there please give me advice on how to do this, what is
needed and or better yet, a simple sample. Say adding dynamic button or
textbox to a form.

Thank you all in advance.

MikeY
 
MikeY,

All you really have to do is call the Add method on the Controls
property that the form exposes. You would pass in the control that you want
to add to the form, and the control's Location and Size properties will
dictate the size and the location of the control on the form.

Hope this helps.
 
Thanks Nicholas. Much appreciated

MikeY

Nicholas Paldino said:
MikeY,

All you really have to do is call the Add method on the Controls
property that the form exposes. You would pass in the control that you want
to add to the form, and the control's Location and Size properties will
dictate the size and the location of the control on the form.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

MikeY said:
Hiya All,

I'm coding in C#, & making a windows application. I am trying to figure out
how to put my dynamic control code in a seperate class (say ie
ButtonClass.cs) so that I can re-use the code with in multiple forms
(ie.frmOne, frmTwo). Being a newbie, I'm not sure if I should try my
hand
at
Interface class or what to do here.

Could anyone out there please give me advice on how to do this, what is
needed and or better yet, a simple sample. Say adding dynamic button or
textbox to a form.

Thank you all in advance.

MikeY
 
Back
Top