|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Equivalent to VCL's DataModuleinto which one can drop non-visual components from the RAD designer. The DataModule is a design-time visual container for non-GUI components, which is never seen visually at run-time as a GUI control. An application or Dll can have any number of datamodules in it, each with its own name. One can also manually add any non-GUI data to any particular DataModule. For an application at run-time, datamodule instances for each visual datamodule are automatically created just like forms, while for a Dll at run-time it is the programmer's responsibility to create datamodule instances for each visual datamodule created at design time. I have found the ability to use datamodules as visual containers to non-GUI components in an application or Dll to be very useful. Admittedly a datamodule is nothing more than a class which contains instances of non-GUI components and possibly other non-GUI fields, but I like the ability to manipulate it at design time, and as a means of separating the data portion of an application or Dll from the GUI portion. Does .NET have any equivalent to this idea, so that non-visual components can be created at design time without having to drop such a component on a Windows or Web form. ? Sounds like you could be thinking of a "component class". In VS 2003 if I
right click on my project, select Add -> Add Component and select Component Class. VS then gives you a C#/VB/C++ class with a "designer page" onto which you can drag drop components and set their properties in the same way as for UI controls on a form. Is this the kind of thing you're looking for? Show quote "Edward Diener" <eddielee_no_spam_here@tropicsoft.com> wrote in message news:OCiOYO0TGHA.2244@TK2MSFTNGP14.phx.gbl... > In Borland's VCL ( Visual Component Library ), one can use a DataModule > into which one can drop non-visual components from the RAD designer. The > DataModule is a design-time visual container for non-GUI components, which > is never seen visually at run-time as a GUI control. An application or Dll > can have any number of datamodules in it, each with its own name. One can > also manually add any non-GUI data to any particular DataModule. For an > application at run-time, datamodule instances for each visual datamodule > are automatically created just like forms, while for a Dll at run-time it > is the programmer's responsibility to create datamodule instances for each > visual datamodule created at design time. > > I have found the ability to use datamodules as visual containers to > non-GUI components in an application or Dll to be very useful. Admittedly > a datamodule is nothing more than a class which contains instances of > non-GUI components and possibly other non-GUI fields, but I like the > ability to manipulate it at design time, and as a means of separating the > data portion of an application or Dll from the GUI portion. > > Does .NET have any equivalent to this idea, so that non-visual components > can be created at design time without having to drop such a component on a > Windows or Web form. ? Clive Dixon wrote:
> Sounds like you could be thinking of a "component class". In VS 2003 if I Bravo ! Yes. I knew MS had to be smart enough to include something like > right click on my project, select Add -> Add Component and select Component > Class. VS then gives you a C#/VB/C++ class with a "designer page" onto which > you can drag drop components and set their properties in the same way as for > UI controls on a form. Is this the kind of thing you're looking for? this in .NET. I guess I should have found it previously, but thanks for bringing it to my attention and seeing this is what I was asking for. The name is a bit misleading to me. I would have preferred it to be called a component container or even a data container since I am guessing I can add non-component value data manually to it also. Show quote > > "Edward Diener" <eddielee_no_spam_here@tropicsoft.com> wrote in message > news:OCiOYO0TGHA.2244@TK2MSFTNGP14.phx.gbl... >> In Borland's VCL ( Visual Component Library ), one can use a DataModule >> into which one can drop non-visual components from the RAD designer. The >> DataModule is a design-time visual container for non-GUI components, which >> is never seen visually at run-time as a GUI control. An application or Dll >> can have any number of datamodules in it, each with its own name. One can >> also manually add any non-GUI data to any particular DataModule. For an >> application at run-time, datamodule instances for each visual datamodule >> are automatically created just like forms, while for a Dll at run-time it >> is the programmer's responsibility to create datamodule instances for each >> visual datamodule created at design time. >> >> I have found the ability to use datamodules as visual containers to >> non-GUI components in an application or Dll to be very useful. Admittedly >> a datamodule is nothing more than a class which contains instances of >> non-GUI components and possibly other non-GUI fields, but I like the >> ability to manipulate it at design time, and as a means of separating the >> data portion of an application or Dll from the GUI portion. >> >> Does .NET have any equivalent to this idea, so that non-visual components >> can be created at design time without having to drop such a component on a >> Windows or Web form. ? > > Why is it misleading?
It is a class that inherits Component. Nothing more, nothing less. Show quote "Edward Diener" <eddielee_no_spam_here@tropicsoft.com> wrote in message news:uGzWEm2TGHA.2156@tk2msftngp13.phx.gbl... > Clive Dixon wrote: >> Sounds like you could be thinking of a "component class". In VS 2003 if I >> right click on my project, select Add -> Add Component and select >> Component Class. VS then gives you a C#/VB/C++ class with a "designer >> page" onto which you can drag drop components and set their properties in >> the same way as for UI controls on a form. Is this the kind of thing >> you're looking for? > > Bravo ! Yes. I knew MS had to be smart enough to include something like > this in .NET. I guess I should have found it previously, but thanks for > bringing it to my attention and seeing this is what I was asking for. > > The name is a bit misleading to me. I would have preferred it to be called > a component container or even a data container since I am guessing I can > add non-component value data manually to it also. > >> >> "Edward Diener" <eddielee_no_spam_here@tropicsoft.com> wrote in message >> news:OCiOYO0TGHA.2244@TK2MSFTNGP14.phx.gbl... >>> In Borland's VCL ( Visual Component Library ), one can use a DataModule >>> into which one can drop non-visual components from the RAD designer. The >>> DataModule is a design-time visual container for non-GUI components, >>> which is never seen visually at run-time as a GUI control. An >>> application or Dll can have any number of datamodules in it, each with >>> its own name. One can also manually add any non-GUI data to any >>> particular DataModule. For an application at run-time, datamodule >>> instances for each visual datamodule are automatically created just like >>> forms, while for a Dll at run-time it is the programmer's responsibility >>> to create datamodule instances for each visual datamodule created at >>> design time. >>> >>> I have found the ability to use datamodules as visual containers to >>> non-GUI components in an application or Dll to be very useful. >>> Admittedly a datamodule is nothing more than a class which contains >>> instances of non-GUI components and possibly other non-GUI fields, but I >>> like the ability to manipulate it at design time, and as a means of >>> separating the data portion of an application or Dll from the GUI >>> portion. >>> >>> Does .NET have any equivalent to this idea, so that non-visual >>> components can be created at design time without having to drop such a >>> component on a Windows or Web form. ? >> Stephany Young wrote:
> Why is it misleading? You are right. I guess the ability that it has to visually contain other> > It is a class that inherits Component. Nothing more, nothing less. components fooled me into thinking it was something special. So I will ask a couple of more questions. Can any component derived class serve as a container for other components if it implements System.ComponentModel.Component's constructor which takes a System.ComponentModel.IContainer as a parameter ? Unlike VCL's DataModule all of the contained components are declared private in the class, which means that they are not accessible outside of the class. What waa the reason for that ? I noticed that my component will only visually accept non-GUI components to be embedded within it in the IDE. That is what I want, but I was wondering what controls that, especially as the System.ComponentModel.IContainer accepts any IComponent interface ? Show quote > > > "Edward Diener" <eddielee_no_spam_here@tropicsoft.com> wrote in message > news:uGzWEm2TGHA.2156@tk2msftngp13.phx.gbl... >> Clive Dixon wrote: >>> Sounds like you could be thinking of a "component class". In VS 2003 if I >>> right click on my project, select Add -> Add Component and select >>> Component Class. VS then gives you a C#/VB/C++ class with a "designer >>> page" onto which you can drag drop components and set their properties in >>> the same way as for UI controls on a form. Is this the kind of thing >>> you're looking for? >> Bravo ! Yes. I knew MS had to be smart enough to include something like >> this in .NET. I guess I should have found it previously, but thanks for >> bringing it to my attention and seeing this is what I was asking for. >> >> The name is a bit misleading to me. I would have preferred it to be called >> a component container or even a data container since I am guessing I can >> add non-component value data manually to it also. >> >>> "Edward Diener" <eddielee_no_spam_here@tropicsoft.com> wrote in message >>> news:OCiOYO0TGHA.2244@TK2MSFTNGP14.phx.gbl... >>>> In Borland's VCL ( Visual Component Library ), one can use a DataModule >>>> into which one can drop non-visual components from the RAD designer. The >>>> DataModule is a design-time visual container for non-GUI components, >>>> which is never seen visually at run-time as a GUI control. An >>>> application or Dll can have any number of datamodules in it, each with >>>> its own name. One can also manually add any non-GUI data to any >>>> particular DataModule. For an application at run-time, datamodule >>>> instances for each visual datamodule are automatically created just like >>>> forms, while for a Dll at run-time it is the programmer's responsibility >>>> to create datamodule instances for each visual datamodule created at >>>> design time. >>>> >>>> I have found the ability to use datamodules as visual containers to >>>> non-GUI components in an application or Dll to be very useful. >>>> Admittedly a datamodule is nothing more than a class which contains >>>> instances of non-GUI components and possibly other non-GUI fields, but I >>>> like the ability to manipulate it at design time, and as a means of >>>> separating the data portion of an application or Dll from the GUI >>>> portion. >>>> >>>> Does .NET have any equivalent to this idea, so that non-visual >>>> components can be created at design time without having to drop such a >>>> component on a Windows or Web form. ? > > Can any component derived class serve as a container for other If the component is to be a container in itself, I would have thought it > components if it implements System.ComponentModel.Component's constructor > which takes a System.ComponentModel.IContainer as a parameter ? would have to either implement IContainer itself or have a Container object to be used as a container for the second level of components, rather than re-use the top-level container. > Unlike VCL's DataModule all of the contained components are declared Usual design guidelines. Make data private and add public properties to > private in the class, which means that they are not accessible outside of > the class. What waa the reason for that ? access the data. You can add your own public properties to the class to access whatever subset of data you need to access, or you can change the accessibility of components in the properties panel ("Modifiers" property), but I would personally do the former. > I noticed that my component will only visually accept non-GUI components Not sure what you mean. I can add a UI control to a component class.> to be embedded within it in the IDE. That is what I want, but I was > wondering what controls that, especially as the > System.ComponentModel.IContainer accepts any IComponent interface ? >> Can any component derived class serve as a container for other Further to my previous answer, I think I might be misunderstanding what you >> components if it implements System.ComponentModel.Component's constructor >> which takes a System.ComponentModel.IContainer as a parameter ? are getting at. If I create a component class in VS, it will generated with: 1) a constructor taking IContainer and calling IContainer.Add(IComponent), so that if you for example drag drop your component onto a form (which is generated by VS containing a Container object), VS ensures that your component will be added to the form's Container object. 2) a private variable of type Container which may be used as the container for other components you drag drop onto your component. Likewise, VS will add that other component to your component's container only if that other component has a constructor taking IContainer (and that constructor would have to call IContainer.Add(IComponent) to work correctly). Clive Dixon wrote:
Show quote >>> Can any component derived class serve as a container for other Thanks for the explanation.>>> components if it implements System.ComponentModel.Component's constructor >>> which takes a System.ComponentModel.IContainer as a parameter ? > > Further to my previous answer, I think I might be misunderstanding what you > are getting at. > > If I create a component class in VS, it will generated with: > 1) a constructor taking IContainer and calling IContainer.Add(IComponent), > so that if you for example drag drop your component onto a form (which is > generated by VS containing a Container object), VS ensures that your > component will be added to the form's Container object. > 2) a private variable of type Container which may be used as the container > for other components you drag drop onto your component. Likewise, VS will > add that other component to your component's container only if that other > component has a constructor taking IContainer (and that constructor would > have to call IContainer.Add(IComponent) to work correctly). Does the IDE know to look for a private variable of type System.ComponentModel.Container in a CLR object in order to have that object act as a container for other objects at design time ? If not, what is the criteria by which an object at design time can act as a visual container of other objects ? > Does the IDE know to look for a private variable of type You can add components to a form or component class even if it doesn't have > System.ComponentModel.Container in a CLR object in order to have that > object act as a container for other objects at design time ? If not, what > is the criteria by which an object at design time can act as a visual > container of other objects ? a container object (try deleting the container object from your wizard generated form or component class and then add components). It's just that if the component you add has a constructor taking IContainer, then VS will add that component to the container object that was created by the wizard - otherwise VS won't add it to the container. I suspect VS's sole criterion for displaying a designer page for a class is that the class derives either from Form or Component, though I don't know for sure. Clive Dixon wrote:
>> Does the IDE know to look for a private variable of type I would assume ever GUI class must have a constructor taking IContainer, >> System.ComponentModel.Container in a CLR object in order to have that >> object act as a container for other objects at design time ? If not, what >> is the criteria by which an object at design time can act as a visual >> container of other objects ? > > You can add components to a form or component class even if it doesn't have > a container object (try deleting the container object from your wizard > generated form or component class and then add components). It's just that > if the component you add has a constructor taking IContainer, then VS will > add that component to the container object that was created by the wizard - > otherwise VS won't add it to the container. else it could not be added to a form, yet when I drop a GUI object onto my component class no code is generated which adds the GUI object to my component class's private container. > Since Form derived from Component, perhaps the criterion is that a > I suspect VS's sole criterion for displaying a designer page for a class is > that the class derives either from Form or Component, though I don't know > for sure. designer page for a class is displayed if that class is a component or derived from a component. Clive Dixon wrote:
> Yes, I agree. Adding properties to the class is better.>> Unlike VCL's DataModule all of the contained components are declared >> private in the class, which means that they are not accessible outside of >> the class. What waa the reason for that ? > > Usual design guidelines. Make data private and add public properties to > access the data. You can add your own public properties to the class to > access whatever subset of data you need to access, or you can change the > accessibility of components in the properties panel ("Modifiers" property), > but I would personally do the former. > I see that now. I do not understand what the use of adding a UI control >> I noticed that my component will only visually accept non-GUI components >> to be embedded within it in the IDE. That is what I want, but I was >> wondering what controls that, especially as the >> System.ComponentModel.IContainer accepts any IComponent interface ? > > Not sure what you mean. I can add a UI control to a component class. to a component class would be, sice I do not think the control would be shown at run-time in any way..
Other interesting topics
Creating simple exe that runs without framework?
Decimal/Single/...: which Numeric-type to use? WebRequest & proxy problem are System.Data.SqlClient.SqlConnection thread safe? can many threads share a System.Data.SqlClient. Process.Start() throws an error saying "Setup error: failed to load resources from resource file Ple |
|||||||||||||||||||||||