Thursday, April 3, 2008

C# : Text box text is not getting refreshed

I had to do a code like the one shown below

txtSample.Text = "Text Sample1";

//few lines of code

txtSample.Text = "Text Sample2";

But it was showing only 'Text Sample2'.

I was looking for a solution and I found that I need to invalidate the rectangle so that the new text will be displayed. There is a method Invalidate() associated with all the controls. But it was not working for me. You need to use the Refresh() method if you need the control fully painted before you take the next step.

No comments:

Post a Comment