Windows form button. Does not work visually

I am creating a windows forms button dynamically wrapped in another control. The problem I'm experiencing is that when I set the Enabled properties with the buttons, it still appears as if it was turned on (not grayed out), however it is not clickalbe. It makes me think that I am not creating the button correctly, or something else like that.

This is the code that I use to create the button.

private System.Windows.Forms.Button CreateWindowsButton(SessionButtonTypes sessionButtonType)
{
        windowsButton = new System.Windows.Forms.Button()
        {
            Top = 3,
            Name = sessionButtonType.ToString(),
            Width = DeterminButtonWidth(guiElement),
            Height = 45,
            FlatStyle = FlatStyle.Flat,
            BackgroundImage = GUI.Instance.GUIImageElement(guiElement)
        };
        // set windows button flat border parameters
        windowsButton.FlatAppearance.BorderSize = 0;

        // for testing
        windowsButton.Enabled = false;
}

[UPDATE] The solution is to put the image element in the image parameter, and not in the background image parameter.

+3
source share
2 answers
Remove `FlatStyle = FlatStyle.Flat`.

FlatStyle , greyed , Enabled false.

+2

, flatstyle "Standard" "System"

0

All Articles