User Control function C#
-
Some time ago I created an application with a similar behaviour (normally I create HMI-applications for machines). I found that the users sometimes entered senseless data into a Textbox. So I created (with the TextChanged-Event) a method to those Textboxes which data has a special format (for example : it must have a legal date or an Integer value or a Phone-number or ...) and give a User-message (MessageBox) to correct this. In the same time I disable the Save-Button. Perhaps this approach helps you ...
I tried your suggestion some time ago. It worked fine, but I could not prevent the buttons to change their enable status. That’s why I’m trying something different.
I continue accepting suggestions and thanks. -
I tried your suggestion some time ago. It worked fine, but I could not prevent the buttons to change their enable status. That’s why I’m trying something different.
I continue accepting suggestions and thanks.Why don't you can disable the Button ? Please explain ...
-
Why don't you can disable the Button ? Please explain ...
Enable and disable the buttons depend on which buttons was pressed. When the user enters the screen, the Save and Cancel buttons are disabled. The other 3 are enabled. When user presses New or Edit buttons, the enable state changes. It's programmed in the User Control, which is generic.
-
Enable and disable the buttons depend on which buttons was pressed. When the user enters the screen, the Save and Cancel buttons are disabled. The other 3 are enabled. When user presses New or Edit buttons, the enable state changes. It's programmed in the User Control, which is generic.
There is no contradiction betwenn my suggestion and your realisation ... If your UserControl has one (or more) Property, which gives this further information to it (for example "the entered data is not valid") you can add all the behaviour you want to have. If you want to work with an UserControl for those functionality it only depends on the "interface" to the rest of the application.