M
mohit
Hello,
I am making a custom control which places some restrictions on the
value of Text property of the control.
While debugging i noticed that when the control is drag-dropped on a
form during Design Time, the InitializeNewComponent method of the
ControlDesigner is invoked. After this the text property of my control
is set to the control name, which Visual Studio automatically assigns(
name of the control object like textBox1 ...).
Now if I want a default blank value in the control's text property i
can set my own designer, override the InitializeNewComponent method and
set the text value after i call the base InitializeNewComponent method
public override void InitializeNewComponent(IDictionary defaultValues)
{
base.InitializeNewComponent(defaultValues);
//over here text property is smthing like MyControl1 or
MyControl2
MyControl control1 =this.Component as MyControl ;
control1.Text = "";
}
My question is why is this happening ??
Even in Microsofts controls like TextBox when I drag the control on the
form during designtime the text property is set to the control's
instance name and then immediately(within milli seconds) cleared.
Thanks and Regards,
Mohit
I am making a custom control which places some restrictions on the
value of Text property of the control.
While debugging i noticed that when the control is drag-dropped on a
form during Design Time, the InitializeNewComponent method of the
ControlDesigner is invoked. After this the text property of my control
is set to the control name, which Visual Studio automatically assigns(
name of the control object like textBox1 ...).
Now if I want a default blank value in the control's text property i
can set my own designer, override the InitializeNewComponent method and
set the text value after i call the base InitializeNewComponent method
public override void InitializeNewComponent(IDictionary defaultValues)
{
base.InitializeNewComponent(defaultValues);
//over here text property is smthing like MyControl1 or
MyControl2
MyControl control1 =this.Component as MyControl ;
control1.Text = "";
}
My question is why is this happening ??
Even in Microsofts controls like TextBox when I drag the control on the
form during designtime the text property is set to the control's
instance name and then immediately(within milli seconds) cleared.
Thanks and Regards,
Mohit