alansiqueira27
alansiqueira27

Reputation: 8506

What's the difference between a button with IsDefault and IsDefaulted?

Can anyone explain me better?

I didn't understand too much just reading the documentation.

Upvotes: 13

Views: 8216

Answers (3)

Chandraprakash
Chandraprakash

Reputation: 978

enter image description here

Once you set IsDefault = "True" for a button, that button click event will be activated whenever you press Enter key anywhere in the form.

Note: If you are inside a control which has attribute AcceptsReturn = "True" Ex: Multiline textbox or listbox, then Enter key will only insert new line and wont activate the default button rather you need to do a Ctrl + Enter key to activate default button

Upvotes: 0

Nitin Purohit
Nitin Purohit

Reputation: 18580

If you set IsDefault to true, button will become the default button for the window i.e. if ENTER key is pressed when the current focus is not on any focusable control that accepts ENTER Key the button click event will be triggerred. If button click event can be triggered due to this default action then IsDefaulted will be true else it will be false. That means if the Default button has focus in this case IsDefaulted will be false as event will not be triggered by default.

IsDefaulted is readonly property which only tells if the button can be clicked by default at present state of focus i.e. the button click event can be triggered on ENTER press when Button did not has the focus. IsDefault we can set to true if we want that button should have this default behaviour i.e. when ENTER key is pressed and even button was not in focus button click should be triggered. We set IsDefault. IsDefault once set to true will remain true but IsDefaulted will change its value depending on which control currently has focus.

Upvotes: 12

Reed Copsey
Reed Copsey

Reputation: 564333

IsDefault determines whether the button is the "default" button for the Window. IsDefaulted will be true if IsDefault is true and the current control with focus doesn't accept an ENTER keypress.

In general, if IsDefaulted is true, it means pressing enter will trigger that button at that point in time.

Upvotes: 10

Related Questions