I am new to winForms. This is the first time I am trying creating a textbox dynamically. It looks there is no problem creating it, but I have problem creating-using my own placeholder. After some search, I am still stuck and got no progress, thanks for any help.
public partial class Form1 : Form
{
Button buttonC=new Button();
TextBox txtOrder = new TextBox();
public Form1()
{
InitializeComponent();
txtOrder.Top = 100;
txtOrder.Left = 300;
this.Controls.Add(txtOrder);
}
private void txtOrder_Enter(object sender, EventArgs e)
{
if (txtOrder.Text == "my_placeholder_text")
{
txtOrder.Text = "";
txtOrder.ForeColor = Color.Black;
}
}
private void txtOrder_Leave(object sender, EventArgs e)
{
if (txtOrder.Text == "")
{
txtOrder.Text = "my_placeholder_text";
txtOrder.ForeColor = Color.LightBlue;
}
}