Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the logical difference between PushButtonState.Default and PushButtonState.Normal?

I am using ButtonRenderer.DrawButton for a column with buttons with images in a DataGridView, and I am interested in when each PushButtonState value should be used.

Here is the official documentation. It says:

  • Default - The button has the default appearance.
  • Disabled - The button is disabled.
  • Hot - The button is hot.
  • Normal - The button has the normal appearance.
  • Pressed - The button is pressed.

The ones I do not understand well are Default and Normal. What is the difference between these two roles? In the screenshot below these 2 roles are combined with the focused bool parameter passed to the ButtonRenderer.DrawButton method.

screenshot

like image 542
silviubogan Avatar asked Feb 27 '26 23:02

silviubogan


1 Answers

About the default state

According to user experience guidelines for Windows-based desktop applications for button control:

The default command button is invoked when users press the Enter key. It is assigned by the developer, but any command button becomes the default when users tab to it.

In windows forms, to set a button as the default button of a form, you can set it as AcceptButton of the form. For more information see How to: Designate a Windows Forms Button as the Accept Button Using the Designer

About other states

If you take a look at ButtonStandardAdapter Which is responsible to draw a standard button, you will see:

private PushButtonState DetermineState(bool up) {
    PushButtonState state = PushButtonState.Normal;

    if (!up) {
        state = PushButtonState.Pressed;
    }
    else if (Control.MouseIsOver) {
        state = PushButtonState.Hot;
    }
    else if (!Control.Enabled) {
        state = PushButtonState.Disabled;
    }
    else if (Control.Focused || Control.IsDefault) {
        state = PushButtonState.Default;
    }

    return state;
}

And IsDefault returns true for a button which is set a AcceptButton of a Form.

like image 122
Reza Aghaei Avatar answered Mar 02 '26 13:03

Reza Aghaei