MarcIT MarcIT - 8 months ago 65
C# Question

c# enable button if textbox has data

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

if a
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
stays disabled even with data in the

Can anyone help?

Thanks in advance

Answer Source

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.)