johnny
johnny

Reputation: 19755

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);
txtAnswer.AppendText(currentValue);

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,

txtAnswer.Clear();

But that doesn't seem right.

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

Upvotes: 0

Views: 29

Answers (1)

SLaks
SLaks

Reputation: 888185

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

Upvotes: 2

Related Questions