Standard-Toolkit icon indicating copy to clipboard operation
Standard-Toolkit copied to clipboard

[Feature Request]: Add `KryptonNumericUpDown` AutoSize property, and auto change when min / max values change

Open giduac opened this issue 3 years ago • 15 comments

Is your feature request related to a problem? Please describe. KryptonNumericUpDown & KryptonDomainUpDown have no AutoSize property. The standard Winforms equivalents have.

Describe the solution you'd like Please, make the property available like in the standard control.

Additional context NumericUD: Sizing the property by hand/mouse in the designer is not possible.

giduac avatar Mar 10 '22 12:03 giduac

@giduac When I place a normal Winform NumericUD on a form and set the AutoSize=true, and run, Nothing happens to the size of the element. What do you expect to happen ?

image

Smurf-IV avatar Jun 26 '22 13:06 Smurf-IV

Hi @Smurf-IV ,

What I thought is that when autosize is on the control re-adjusts it's width when the inner text becomes larger than the visible area.

I obviously didn't test this when I posted this FR. But have done so now. The winforms nud has the autosize property but does not react to it when the text/number becomes out of bounds. This also goes for the DomainUD.

So this FR can be closed.

giduac avatar Jun 27 '22 08:06 giduac

Thanks for confirming.

Smurf-IV avatar Jun 28 '22 06:06 Smurf-IV

Hi @Smurf-IV ,

I've been having deeper look at this and it actually does work but in a different way than you would intuitively expect. The Krypton versions lack this behaviour.

I'll post a sample app with findings here later on and we can see what kind of FR(S) to create from this or let things be as they are...

giduac avatar Jun 28 '22 08:06 giduac

Hi @Smurf-IV ,

Findings below. I used videos which illustrate things better imo.

Tested with net48/50/60

Winforms DUD & NUD

  • Docs: AutoSize property documentation, for both controls, does not state correctly how this works.
  • Resizing visually in the designer is only possible when AutoSize is set to false (this is default behaviour);

Winforms NUD:

  • Docs: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.numericupdown?view=windowsdesktop-6.0
  • The AutoSize is coupled to the maximum value property which is used to determine the maximum text width needed.
  • When the maximum value is changed at runtime AutoSize needs to be turned off and on again so the size can be recalculated by the control and updated.
  • Might be automated through a change of the maximum property and triggered if AutoSize == True

Winforms DUD

  • Docs: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.domainupdown?view=windowsdesktop-6.0
  • The auto size is determined from the longest string in the Items list property
  • If the list would be changed at runtime, to make sure the width remains correct the autosize needs turning off and on to trigger resizing.
  • Might be automated through a change to the Items list and triggered if AutoSize == True

Out of scope but a bug in .NET (net48/50/60 tested) and will file a bug request with them:

  • If at runtime the item list is set to contain only 1 item this item cannot be selected in the control. Neither by clicking the arrow-keys nor using the up/down keys.
  • Found this by editing the list via a property grid.
  • Also happens when done through code.

Possible FRs

  • I think this is a good addition but it also needs a better explanation in the .NET Help (I might file a FR with them). When the property is selected in the IDE a better help text could be shown at the bottom of the property grid.
  • Add the AutoSize property to the Krypton equivalents
  • The functionality could be extended to resize the control, if needed, when the Maximum value changes or for DomainUD the Items list changes. This could be done if AutoSize == True by turning AutoSize off and on

Resizing the KryptonNUD in the designer (possibly a separate Bug ticket):

  • Is not possible although the grip on the right and left is visible.
  • If the left grip is dragged the control is moved. If the right is dragged nothing happens

Videos

  1. NUD AutoSize behaviour
  2. DUD AutoSize behaviour
  3. NUD Resizing visually in the designer

https://user-images.githubusercontent.com/96108132/176381568-33a992e2-2f7f-4de2-aa2f-3c4838a18868.mp4

https://user-images.githubusercontent.com/96108132/176381627-314a2f7b-b47e-4cf1-9155-5aa78095793d.mp4

https://user-images.githubusercontent.com/96108132/176381652-ee0b813e-5af9-4578-8123-5ba70a28be4e.mp4

giduac avatar Jun 29 '22 07:06 giduac

Resizing the KryptonNUD in the designer (possibly a separate Bug ticket):

Is not possible although the grip on the right and left is visible. If the left grip is dragged the control is moved. If the right is dragged nothing happens

This "should" have been sorted via a separate bug a little while ago.

Smurf-IV avatar Jul 16 '22 10:07 Smurf-IV

Might be automated through a change of the maximum property and triggered if AutoSize == True

The "Auto Display Width" also needs to alter if the minimum string is also longer than the max string !

Smurf-IV avatar Jul 16 '22 10:07 Smurf-IV

@giduac Refocusing this "Title" to the work that will need to be done.

Smurf-IV avatar Jul 16 '22 10:07 Smurf-IV

Note: This one is not going to be easy, due to the designer issues, and the use of min size will need to be "Turned on" if AutoSize = true

Smurf-IV avatar Jul 16 '22 10:07 Smurf-IV

@Smurf-IV

Nice.

Btw: do you want an extra bug ticket for the KNUD to fix resizing in the designer (3rd video) ? ...

giduac avatar Jul 16 '22 10:07 giduac

Btw: do you want an extra bug ticket for the KNUD to fix resizing in the designer (3rd video) ? ...

No, It's not a problem, in the alpha branch that I have from 2022-06-25, I'm about to get Latest alpha, and check

Smurf-IV avatar Jul 16 '22 10:07 Smurf-IV

No, It's not a problem, in the alpha branch that I have from 2022-06-25, I'm about to get Latest alpha, and check

It's "Still" okay ;-) NUD_DesignerDrag

Smurf-IV avatar Jul 16 '22 10:07 Smurf-IV

Hi @Smurf-IV

Confirming the above fix in Nightly: 70.22.7.200-alpha

giduac avatar Jul 19 '22 07:07 giduac