Hello All,
When creating a Windows Forms UserControl, is there any way to tell if its
container is in the midst of its InitializeCompo nent call, other than setting
a property?
For instance, say I have a control called SomeControl that contains some
properties Property1, Property2, ..., PropertyN. Each of these properties
may do something time consuming, like accessing a database or updating UI,
etc. The constructor may set up some default stuff.
Then, I have a test container that does something like:
private void InitializeCompo nent()
{
this.MySomeCont rol = new SomeControl();
// Initialize some other stuff
// |
//
// MyUTM
//
this.MySomeCont rol.BackColor = System.Drawing. SystemColors.Co ntrol;
this.MySomeCont rol.Dock = System.Windows. Forms.DockStyle .Fill;
this.MySomeCont rol.Property1 = "SomeHostNa me";
this.MySomeCont rol.Property2 = "MyUserName ";
// more properties
this.MySomeCont rol.PropertyN = Colors.Red;
this.MySomeCont rol.Location = new System.Drawing. Point(0, 0);
this.MySomeCont rol.Name = "SomeContro l";
this.MySomeCont rol.Size = new System.Drawing. Size(760, 566);
this.MySomeCont rol.TabIndex = 8;
}
Is there any way to prevent the processing of all the properties until the
test client is done initializing? I don't want to process Property1, then
Property2, then PropertyN - instead I want to process PropertyN only.
Thanks,
pagates
When creating a Windows Forms UserControl, is there any way to tell if its
container is in the midst of its InitializeCompo nent call, other than setting
a property?
For instance, say I have a control called SomeControl that contains some
properties Property1, Property2, ..., PropertyN. Each of these properties
may do something time consuming, like accessing a database or updating UI,
etc. The constructor may set up some default stuff.
Then, I have a test container that does something like:
private void InitializeCompo nent()
{
this.MySomeCont rol = new SomeControl();
// Initialize some other stuff
// |
//
// MyUTM
//
this.MySomeCont rol.BackColor = System.Drawing. SystemColors.Co ntrol;
this.MySomeCont rol.Dock = System.Windows. Forms.DockStyle .Fill;
this.MySomeCont rol.Property1 = "SomeHostNa me";
this.MySomeCont rol.Property2 = "MyUserName ";
// more properties
this.MySomeCont rol.PropertyN = Colors.Red;
this.MySomeCont rol.Location = new System.Drawing. Point(0, 0);
this.MySomeCont rol.Name = "SomeContro l";
this.MySomeCont rol.Size = new System.Drawing. Size(760, 566);
this.MySomeCont rol.TabIndex = 8;
}
Is there any way to prevent the processing of all the properties until the
test client is done initializing? I don't want to process Property1, then
Property2, then PropertyN - instead I want to process PropertyN only.
Thanks,
pagates
Comment