Control as a form within an object

  • Thread starter Thread starter web1110
  • Start date Start date
W

web1110

Hi y'all,

I have a set of objects and within each, I want to provide a method to
display the contents of the object. I also wish to be able to use the form
designer part of Visual Studio to create each form.

The solution I came up with is to create a Windows control library and then
instantiating the control in the containing object. Problem is, I am
drawing a blank on how to display this control dynamically (ie upon
request).

Also, if anyone has a better method of achieving this, I would appreciate
the assistance. I am not particulary fond of this solution.
 
web1110 said:
Hi y'all,

I have a set of objects and within each, I want to provide a method to
display the contents of the object. I also wish to be able to use the form
designer part of Visual Studio to create each form.

The solution I came up with is to create a Windows control library and then
instantiating the control in the containing object. Problem is, I am
drawing a blank on how to display this control dynamically (ie upon
request).

Also, if anyone has a better method of achieving this, I would appreciate
the assistance. I am not particulary fond of this solution.

IMO, and if I understand your formulation correctly, your problem is one of
direction.
(form ->classes) If you have a Form, you can display in it values derived
from Other classes.
(classes -> form) you will have your problem.
If, for each Other class, the form should be Different, then you need
Different forms, and call them from Form. Then you will need to have some
parameter procedure in the calling Form, e.g. a couple of buttons, each
calling a Different form.
 
Hi again,

The situation is this:

Each object is a subassembly. They are all significantly different in
detail and content but are all derived from an abstract subassembly class.

An assembly is defined as a tree of subassemblies. There are multiple
levels of subassemblies that can be assembled in many different
configurations. Someone on the production floor can open an assembly object
and request information regarding that particular object. One subassembly
requested method (among many) would be a list of subassembles within that
object.

If required, a subassembly can be be selected and displayed via a method
specified in the abstract class definition. What I want to do is direct the
subassembly to display itself as a form on the CRT. So, what I want to do
is build into each of these subassembly objects a form method to display its
content. I want the form to exist within the subassembly although the
subassembly, itself, is not a form.

It would be much easier to maintain such a system if I could use the VS form
designed capabilities (as oppopsed to dynamically building a form within the
assembly). So, the sequence would be as follows:

1, Open Assembly
2. Display subassemblies
3. Select subassembly
4. Direct subassembly to display itself
5. Display subassemblies
6. Select subassembly
7. Direct subassembly to display itself
8. ...

This can be repeated to 'n' levels of subassembly.

A sloppy method but equivalent method (IMHO) would be to create a form
application for each subassembly which would be fired off by the subassembly
object when a request is made with the invocation providing the necessary
data retrieval information. I do not like this. I want to find a method
that I can use to include this display mechanism in each subassembly object,
thus encapsulating everything within a subassembly to one inclusive object.

Thanx all,
Happy Ramahanakwasmas
WEB
 
Have your components derive from UserControl and override the paint method
to let it custom-draw itself. Then add this to the container form by adding
to the Controls collection and setting its location to place it within the
form.

To invoke the custom method on the object, just define a common interface
containing the method and invoke it polymorphically.

Hope that helps.
 
John,

Thank you much.

I haven't had to play with paint. Can you point me to a tutorial to help
get me started.

Thanx,
WEB
 
Back
Top