What is the best way of adding various user Controls? [Win #C]

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

MikeY

Hi everyone,

I'm trying to figure out, on my windows form, of what is the best way to add
various custom controls at various times during run-time. The problem is
that they will need to be in the same spot as each other, depending on what
is being called at that particular time by the user. I have been trying to
use Inherited user controls, but I am not able, and/or don't know how to
retrieve the data from my Inherited user control. If the controls were
actually pre-contained then I use regular delagates, but with Inherited
controls I am unsure of the options. I also believe that I cannot add my
regular built custom controls at runtime and pass data from my delagates.

So if there are any suggestions, links, sample syntax's would be
appreciated.

MikeY
 
Hi,


Not sure what you mean with user controls (I've only seen this term in web
escenarios)
Anyway, all you have to do to add a control is create it, set the properties
(location, text, etc) and add it to the Controls collection of the correct
container (TabPage, Form)

Accesing the especific properties can be achieved by casting:

MyControl c = (MyControl) this.Controls[0];
 
MikeY,
Generally what I do is use a Tab Control where the entire Tab surface is
covered by the requisite usercontrol, or if you have a smaller area you can
put the usercontrol into a Panel or GroupBox.

Hope that helps.
Peter
 
Actually that really is a good solution Peter. In fact I'm going to give
that one a go.

Much appreciated & thanks everyone.

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

Back
Top