I am trying to add System.Windows.Forms.Control to this form management collection. I do this by creating a personal type control field and then creating this field for a new instance of System.Windows.Forms.Control in the constructor.
At runtime, I try to change the type of the _placeholder variable in a TextBox by doing something like the following code example. So basically I'm trying to have a placeholder like Control and change it to another control like TextBox or Label at runtime. My problem is that nothing appears on my form? Any insight would be appreciated.
public class MyForm : Form { System.Windows.Forms.Control _placeholder = null; public MyForm() { _placeholder = new System.Windows.Forms.Control(); this.Controls.Add(_placeholder); ChangeToTextBox(); } public void ChangeToTextBox() { _placeholder = new TextBox(); } }
source share