i have a .NET control which a user can drop on a form.
Visual Studio creates a InitializeComponent, which is called from the hosting form’s constructor:
public EditItemForm()
{
InitializeComponent();
}
This auto-generated method, in an auto-generated file, initializes my control based on designer serializiblity rules. e.g.:
private void InitializeComponent()
{
...
this.lvResults = new Contoso.Controls.VirtualGrobber();
...
//
// lvResults
//
this.lvResults.BorderStyle = System.Windows.Forms.BorderStyle.None;
...
//FrobGrobberForm
...
this.Controls.Add(this.lvResults);
...
}
How can i, a Control sitting on someone’s form, know when all the designer serialization is done, and i’m “ready”?
In Delphi, the mechanism that serializes in a control automatically calls each control’s Loaded method:
Initializes the control after it is loaded from a stream.
procedure Loaded; override;Description
The VCL streaming system calls Loaded
automatically after the control’s form is loaded into memory so that
the control can complete any initializations that depend on other
objects in the form.
Implement the
ISupportInitializeinterface. Visual Studio will add code to the form designer code file that callsEndInitwhen it’s done setting all the component’s properties.