MarcIT MarcIT - 17 days ago 10
C# Question

c# enable button if textbox has data

EDIT:
Sorry for the lack of information, its a winform app in C#
And the post is not duplicate.
The problem happens when i close the form witch contains the report to edit the previous form values and then the button to print the report again stays disabled instead of remaining enabled.

So now i got locked from posting more questions... :|

I found several similar posts but none resolved my issue.
I have the following code do enable a

button
if a
textbox
is empty:

button3.Enabled = string.IsNullOrWhiteSpace(resposta.Text);


The code works but the problem is, if i click next and for some reason want to go back to alter something the
button
stays disabled even with data in the
textbox
.

Can anyone help?

Thanks in advance

Answer

Well, it's a but unclear what the problem is, but it seems you are trying to use WinForms as some MVC with binding (like angular), but when you do assignment it does this one time only in WinForms, no binding is created.

So you need to figure out when you need to call this again. (TextChange, some button click, etc.)