johnny johnny - 1 year ago 85
C# Question

How do I AppendText to a textbox at the time it is entered without duplication in C# Forms?

I have in a button click event.

Button v = (Button)sender;
currentValue = currentValue + Convert.ToString(v.Tag);

If v.Tag's value is 2 and I click the button twice, I get 2, 22, 2222, etc. for AppendText. I can use something like a condition with,


But that doesn't seem right.

How do I keep it from doubling up? currentValue acts correctly. AppendText does not.

Answer Source

You can set the text directly by assigning to .Text.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download