Dynamic Contorls & Classes

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
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
M

MikeY

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top