Autometically remove default text from textbox
In C# how to remove default text autometically from textbox when user select a textbox to enter someone.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Mar 20, 2013, 6:12 PM
When you create it, you need to add an extra line to 'wire up' the Enter event:
txtDynamic.Enter += txtDynamic_Enter;
You now need to add the handler manually rather than via the VS designer as you would with 'static' textboxes:
private void txtDynamic_Enter(object sender, EventArgs e)
{
TextBox tb = (TextBox)sender;
tb.Text = "";
}
Note that you can use the same event handler for any number of dynamic textboxes. The 'sender' parameter knows which one is being entered.
VulpesPosted Mar 21, 2013, 12:03 PM
Arun KurmiPosted Mar 21, 2013, 8:08 AM
I give name for dynamic textbox txt1,txt2,.......so control called as txt1,txt2,......
i tried to wire control different types as commented in below code but not solve my problem.
Again thanks in advance.
for (int i = 0; i < n; i++)
Jignesh TrivediPosted Mar 21, 2013, 12:12 AM
hi,
if your are web developer than you can use onclick or onfocus event of javascript.
or
if you are window form developer than above approch is good one.
Arun KurmiPosted Mar 20, 2013, 1:34 PM
VulpesPosted Mar 19, 2013, 12:33 PM