Another question about the UltraNumericEditor...
I am binding the UltraNumericEditor to a nullable double (aka double?, aka Nullable<double>). If the value really is null, I'd prefer not to display a number in the control. I can do this no problem. However, the user must then enter a number manually into the control rather than hit the spin buttons (they are greyed out). I can also, use the DataBindings - Advanced to set up a value for when the underlying business object is null. However, this isn't really appropriate either as it gives the user the impression that there is a value already in the model.
One solution would be to display nothing (or perhaps the word "Null" or "Enter a value"?) in the control BUT have the spin buttons enabled. When the spin button is first hit, the values should start from some value (say 0.0 or 1.0). Is this possible?
Any ideas on best practices or relevant posts would be most appreciated. I did look through the posts, but in this case, it's hard to even know the keywords to search on.
I have attached a simple project that shows to UltraNumericEditors bound to the the same business object. In one, I don't bother to set a default value, and the user must type inside the edit box to get going. In the other, I use the DataBindings - Advanced to set a default value. Neither solution is ideal.
Thanks,
Andrew
I should have pointed out that by removing the SpinIncrement Property, I can get the up/down arrows to be enabled. However, hitting the up array moves the number in the 1's place which may or may not be what is desired. Again, I'd like to know what the possibilities are. Perhaps you have an example or tutorial?
Thanks Chris,
I was able to get things working using the Nullable property. As you said, when you now hit the spin buttons, it starts at the minimum value.
One thing that might be nice (if possible) would be to start at some value other than the minumum. For motivation, consider the following case. You want your user to pick a value and thus you assign null to the property. You take the attitude that he MUST pick the value, not get a default. However, you know that 90% of your users will pick 0.5 (range is 0.0 to 1.0). Is there a way to have the control display .5 first? The other motivation is that 0.5 is in the middle. Even if they are going to pick some random value between 0 and 1, .5 is going to be closer than 0 most of the time. Is it possible?
Chris et al:
Is there a simple way to have the spinner start at some value other than the minimum when the user first starts spinning (see previous post)? I'm now getting requests for this behavior.
Thank you for providing additional information along with a sample. It appears the behavior you are encountering is being caused the by use of the DataFilter with the SpinIncrement functionality.
When using a SpinIncrement, the entire Value of the control is validated against the MinValue and MaxValue, instead of being processed on a sectional basis. The DataFilter is changing the underlying value to be outside the valid range.
Based on my initial glance through the relevant code, I believe this is a scenario that needs to be addressed. As such, I have passed this information to our Developer Support department to have a support case opened on your behalf.
In the meantime, a simple modification to your business class can be used in place of the DataFilter. Within the BusinessClass, you can create a new property (for each property you want displayed as a percentage). You can then bind to these new properties, as they will perform the percentage data conversion in place of the DataFilter.
public Nullable<double> DistributionPercentage { get { return (_distribution == null)? null : (_distribution * 100); } set { _distribution = (value == null) ? null : (value / 100); } }
public Nullable<double> Distribution2Percentage { get { return (_distribution2 == null) ? null : (_distribution2 * 100); } set { _distribution2 = (value == null) ? null : (value / 100); } }
You should receive a notification from our Developer Support department shortly regarding your support case. If there is anything else I can do to help or if you have further questions, please don't hesitate to ask.
Thank you, Chris
I talked the customer into a compromise. Instead of going from 0-100 (for example), the spinner will go from 20-100. I.e. user has to enter a value between 20 and 100. However, I believe I may have found a bug with your control. I have attached a very simple project that demonstrates it. I have two numeric controls one that goes from 0 to 100, and one that goes from 20 to 100. Both controls are databound to a businessclass. Both controls use a a DataFilter. I got the class to use for the datafilter from a post by an Infragistics employee.
You will see that the control going from 0 to 100 works perfectly. The one from 20 to 100 "jams" at 20. The only difference is the range picked on the properties, and the initial values. They are both bound to Nullable<double> so their initial appearance is blank.
What is going on? Bug or something simple I'm overlooking. If I had to guess, the DataFilter class may not be optimum as things work when I have no data filter class and use 20-100 in the GUI and 20-100 in the model. However, the customer wants 20-100 in the GUI and .2-1 in the model. Sigh.
Unfortunately, the ability to set the default value when spinning from Null does not exist as part of the current spinning functionality.
You can work around this by implementing the incremental spinning yourself by adding a SpinEditorButton to the ButtonsRight collection, and hiding the default spin buttons. You can then handle the EditorSpinbuttonClick event and modify control’s Value based on its current value and the direction being spun.
I would also recommend that you submit a feature request to expose a property for Default Value when attempting to spin from Null. This will give the feature some priority on the product manager’s feature-implementation list, as well as make sure you at notified should it be implemented in a future release.
Chris