Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Ribbon NumericUpDown not disabling. #141

Open
Tape-Worm opened this issue Apr 14, 2019 · 4 comments
Open

Ribbon NumericUpDown not disabling. #141

Tape-Worm opened this issue Apr 14, 2019 · 4 comments
Labels
bug under investigation Investigation of bugs/issues

Comments

@Tape-Worm
Copy link
Contributor

Tape-Worm commented Apr 14, 2019

I have 2 numeric up down controls on the ribbon, along with 2 labels.

On startup of my application, these labels and numerics should be disabled. But, only the labels are disabled.

image

If I change the Enabled state on the numeric by clicking the "Fixed Size" button, the numerics will disable just fine.

I've walked through the code with the debugger to ensure that the Enabled flag is being set to False at startup (this also happens if I set Enabled to False in the designer), and it is being set (and the property returns False as it should), yet they are still enabled.

All other control types that I have on the ribbon behave properly, so far, only the numeric is not behaving correctly.

@Tape-Worm
Copy link
Contributor Author

And ... now.. for some reason, it's working. I have no idea why. I'm going to close this for now since it's working as it should.

@Tape-Worm Tape-Worm reopened this Apr 16, 2019
@Tape-Worm
Copy link
Contributor Author

Tape-Worm commented Apr 16, 2019

OK, so, for some inexplicable reason, the numerics are no longer staying disabled again on startup.

Here's the weirdness of it all:
I had the numerics disabled in the IDE. I run the app, and go to the tab and the numerics are enabled (they shouldn't be). So, I enable them in the IDE, and now they're disabled on startup (as they should be). When I originally opened this issue, I had the opposite problem. And disabling them in the IDE worked (even though I'm setting .Enabled = false in the code!)

This is quite schizophrenic.

@Tape-Worm
Copy link
Contributor Author

Tape-Worm commented Apr 16, 2019

OK, so I just ran the Ribbon Controls 2019 demo, and disabled the numericUpDown1 on the ribbon:
image

And when I run the code:
image

It also does not appear to respect the ReadOnly property either.

@Tape-Worm
Copy link
Contributor Author

Tape-Worm commented Apr 16, 2019

So, digging through KryptonRibbonGroupNumericUpDown.cs, I noticed that the Enabled property uses an internal private variable to store its state. This is fine, but the underlying control is not updated.

It looks like it gets updated at runtime via the PropertyChanged event, but not on initialization. So basically, by setting Enabled = false in the designer, we end up with a control wrapper that is out of sync with it's underlying control. This would explain the really crazy behavior I saw (beyond that of not respecting the flag - weird flashing everytime the property was set, big performance hits, etc...)

For giggles, I added this to the enabled property (after the _enabled assignment):
NumericUpDown.Enabled = value;

That seems to have cleared up the issue. To fix this, I'd probably get rid of the internal private variable tracking the enabled state, and just use the Enabled property on the underlying control as a mirror. Same with any other property exposed. And any property that does not fit the context of the control wouldn't be exposed at all.

Of course, my concern here is that if the state flag is removed and replaced with the underlying Enabled property, what will it break? Was it done this way for a specific purpose?

@PWagner1 PWagner1 added bug under investigation Investigation of bugs/issues labels Apr 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug under investigation Investigation of bugs/issues
Projects
None yet
Development

No branches or pull requests

2 participants