Krypton-Suite / Standard-Toolkit

An update to Component factory's krypton toolkit to support .NET Framework 4.6.2 - 4.8.1 to .NET 6 - 8
BSD 3-Clause "New" or "Revised" License
393 stars 58 forks source link

[Bug]: ComboBox does not update when Enabled is changed #1296

Closed KAINLabs closed 3 months ago

KAINLabs commented 8 months ago

When changing the Enabled property from false to true, the color style remains disabled and the control cannot be interacted with, even though the property says it is set to true/enabled.

To Reproduce Steps to reproduce the behavior:

  1. Add a KryptonComboBox to a form and set the combo box's Enabled property to false at design time.
  2. During runtime, programmatically change the combo box's Enabled property to true.
  3. The combo box does not visually change, nor can it be interacted with.

Expected behavior The visual color scheme should change to active/enabled and the user should be able to interact with it.

Desktop

Additional context Looking at the source code for the KryptonComboBox, this issue may have something to do with there being 2 OnEnabledChanged override events in the control. The newer one has comments about not forwarding the event as a fix for issue 662.

PWagner1 commented 8 months ago

Hi @KAINLabs

Thanks for reporting, just 'fixed' it, but changes don't show up in the designer. Any thoughts @Smurf-IV?

Smurf-IV commented 8 months ago

but changes don't show up in the designer. Any thoughts @Smurf-IV?

You have to add an attribute so that the designer forces a refersh of the displayed control when the value changes.

PWagner1 commented 8 months ago

but changes don't show up in the designer. Any thoughts @Smurf-IV?

You have to add an attribute so that the designer forces a refersh of the displayed control when the value changes.

RefreshProperties attribute?

Smurf-IV commented 8 months ago

RefreshProperties attribute?

Yes that's appears to be the one I was thinking about..

And / Or checking if InDesignerMode and calling Refresh() to perform a designer invalidate.

PWagner1 commented 8 months ago

Fixes may need to be applied to all controls.

PWagner1 commented 8 months ago

Hmm... I don't understand why this won't work?

 /// <inheritdoc />
        [RefreshProperties(RefreshProperties.Repaint)]
        public new bool Enabled
        {
            get => base.Enabled;

            set
            {
                base.Enabled = value;

                if (DesignMode)
                {
                    Refresh();
                }
            }
        }
Smurf-IV commented 7 months ago

@Wagnerp re: The commit referenced above; What did it do for this bug ?

Because you started down the designer route, when the Original was at runtime ?

PWagner1 commented 7 months ago

@Wagnerp re: The commit referenced above; What did it do for this bug ?

Because you started down the designer route, when the Original was at runtime ?

@Smurf-IV Nothing, works at runtime but not in the designer. But I think this is standard WinForms practice.

giduac commented 3 months ago

@Wagnerp

Is this one still on or cant it be closed, since Smurf added the wont fix label?

PWagner1 commented 3 months ago

@Wagnerp

Is this one still on or cant it be closed, since Smurf added the wont fix label?

@giduac

Works at runtime, but not in the designer, just like any other WinForm control. So I'd say yes.