Sharing .net controls?

  • Thread starter Thread starter viboater
  • Start date Start date
V

viboater

Is it possible to share controls, ie a label or a textbox, amoung Group
Boxes?

I have some statistics info that I display on a couple of different
forms and it would be nice to be able to maintin one control rather
than multple controls.

Thanks
 
First, no it's not possible. A control can have only one parent
container, and one location within that container.

That said, the secret is to share the code that maintains the controls,
not share the controls themselves. A lot of people using Microsoft's
(.NET) DataBinding classes to connect controls to sources of data. I
can't stand them, personally (I think that they have enough problems
that they're more trouble than they're worth). However, they're not the
only game in town.

Read up on the Java pattern "Model-View-Controller" for an idea of how
to separate the logic that provides the data from the screen controls
themselves. Implementing a complete MVC architecture is maybe a bit
more than you need, but the basic concepts should apply.

As well, if you read up on MS's DataBindings, the ideas behind them may
be very helpful, too, even if you don't use DataBindings. Myself, I
wrote my own bindings, and writing screens is a breeze now.
 
Back
Top