G
Guest
Hi!
I would like to use a component to add a control to a form. This will be
used to make a component that can enable/disable visual features on a form
without making every feature a toolbox item.
I can add and remove the control to the forms component container by using
the following code:
private bool m_bDisplayTextBox = false;
private TextBox tbTest = new TextBox();
[DefaultValue(false)]
public bool DisplayTextBox
{
get { return(m_bDisplayTextBox); }
set
{
if(value == true) this.Container.Add(tbTest);
else this.Container.Remove(tbTest);
m_bDisplayTextBox = value;
}
}
This will make the TextBox visible in the dropdown list in the properties
browser, but it will not be visible on the form itself. I have pined this
down to the fact that there is no line containing
"this.Controls.Add(this.textBox1);" added to "Windows Form Designer generated
code" in the Form class.
How can I also get the "this.Controls.Add(this.textBox1);" added to the Form
class "Windows Form Designer generated code"?
BR
Christian Wikander
I would like to use a component to add a control to a form. This will be
used to make a component that can enable/disable visual features on a form
without making every feature a toolbox item.
I can add and remove the control to the forms component container by using
the following code:
private bool m_bDisplayTextBox = false;
private TextBox tbTest = new TextBox();
[DefaultValue(false)]
public bool DisplayTextBox
{
get { return(m_bDisplayTextBox); }
set
{
if(value == true) this.Container.Add(tbTest);
else this.Container.Remove(tbTest);
m_bDisplayTextBox = value;
}
}
This will make the TextBox visible in the dropdown list in the properties
browser, but it will not be visible on the form itself. I have pined this
down to the fact that there is no line containing
"this.Controls.Add(this.textBox1);" added to "Windows Form Designer generated
code" in the Form class.
How can I also get the "this.Controls.Add(this.textBox1);" added to the Form
class "Windows Form Designer generated code"?
BR
Christian Wikander