Textbox.Text is changing the actual value but not the visual !

OmriDulla

New member
Joined
Nov 19, 2023
Messages
4
Programming Experience
1-3
I am developing c# winforms software,
When user presses "הוסף" button the software does something and increases "קוד מוצר" by one (12451) must be (12452) after pressing "הוסף"
p1.png



The actual value is incresing, but I don't see the change on textbox, here is the codeline that must increases it, as you can see below the calue of codeText.Text is 12451
p2.png


after that code line and value of codeTxtB.Text is changed, as you can see 12452, but on textbox visually its still 12451. what could be wrong?
p3.png
 
Line 129 is setting codeTxtB.Text to something else a couple of lines later. You're not going to see the UI updated until that method completes and, by then, that property has been set to something else. If you were to call the Refresh or Update method of the TextBox at that point, you would see the UI updated.
 
By the way, it's pretty poor form to use that TextBox for data storage. Not quite as bad as using a Label but almost. If you want to store an int value, use an int variable. When you want to increment, do it to that variable and then display that variable's value in the TextBox.
 
Back
Top Bottom