Home > OS >  Button will be locked until radiobutton, textbox, checkbox and combo box is ticked
Button will be locked until radiobutton, textbox, checkbox and combo box is ticked

Time:02-21

I know this might be simple for most of you but I need help.

btnBuild shouldn't be clickable until the textbox1 have been filled out, radio button, check box and combo box have an item that is selected. And when the btnReset is clicked the btnBuild will return on being not clickable since all the field will be cleared. I already have a code for the btnReset, only the btnBuild being unclickable is my problem.

CodePudding user response:

I'd suggest using an event modified for every mandatory field and do something like this:

if (string.IsNullOrEmpty(textbox1.Text))
        {
            btnBuild.enable =false;
        }

Why use event 'modified'? Because each time the content of a field changes, you want to make sure there's still something in there. Then if it's empty, disable btnBuild. Could also use an error provider. Keep also in mind that a textEdit item, uses the '.Text' property to check if it has a value, whereas a DateEdit item, needs the '.EditValue', sp find the apropriate property for each different item you use. It would also be helpfull to post the btnReset code.

CodePudding user response:

Just add this to the bottom of your btnReset click event.

btnBuild.Enabled = false; 
  • Related