1/10/2024 0 Comments Devexpress errorproviderIf the container field does not exist then things work a little differently. When you add a control to the form and the container is defined and it contains a ctor that accepts a container then the designer will hookĮverything up. Now, the default generated code for a new form will contain the container declaration and initialization. (because it can access it via a separate property) but components do (because they don't have access to the parent). The general guideline is that control's don't care about the container If a control doesn't care about the container list then the designer won't bother generating the code to create one. The control to have access to the container if it needs it. Almost every control (at least the framework ones) exposes a ctor that accepts the container as a parameter. ![]() Not every control needs or requires access to the parent container (the components field). Only version that would be patched in the future. I'd also be interested in knowing if it occurs in VS2010 as this is the You'd have to identify the reproducible steps needed before we could determine if it is a bug or not. However the designer will probably not do anything if it already exists. In general if you delete the component field declaration and creation then the designer should consistently recreate it for the same component (but might do different things for different components). I've only seen one or twoĬomponents that ever really needed the parent container and this was strictly because they needed to find other components.įinishing up, is it a bug? Not sure. For the few components that really, really need the parent container they can use the site to get it (if it was set). ISite interface allows access to the container associated with the site (the form). This can be set after the component is created. It is the exact inverse of what you might expect (where the component uses the container).Ĭomponent has a seldom used property called Site of type ![]() In fact the defacto implementation of a component that accepts a container is to simply add the component to the container's list. As a result most components will work without a parent container This is a convenience feature more than a requirement. Most (or perhaps all) IEPs derive from Component just so they can show up in the toolbox (which shows components+). For example it is pretty common to just create and use an instance of BWC directly in code rather than attaching it to a form. All this class really does is provide some support to derived types for working with the parent container.Ĭomponents do not require that they be housed in a container. The only problem with IEP is that, generally speaking, you want users to be able to drag and drop said class onto a form so they don't have to write the code by hand.Ĭomponent (from which Control derives) handles the non-UI interaction with the parent container (if any). This allows it to "attach" to other types. ErrorProvider) then it generally implements If the class extends existing controls (ie. ![]() Need a UI then it can be a regular old class. When you're creating a new class that you want to use in a form you have to decide what base class it will have. Why might this be happening? Should I be woried about this? You can see that the errorProvider's constructor is not passed the 'components' variable, neither is 'components' initialized. Now the code that is generated when the designer does no recognise the 'components' variable: This.DoubleClick += new System.EventHandler(this.Form1_DoubleClick) This.AutoScaleDimensions = new (6F, 13F) First the code that is generated in a clean new project with just one component on the form: private void InitializeComponent() I'm having trouble with the code that is generated automatically by the WinForms designer, sometimes it generates code that uses the 'components' (IContainer) in the constructors of disposable components and other times it doesn't.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |