Spinner value = integer ?

Oct 9, 2008 at 3:28 PM
I am trying to automate a number of Spinner (NumericUpDown) controls in my WinForms application.

The NumericUpDown value property is a decimal - however, the White implementation of the Spinner control only allows integer values - is this a bug / oversight or is it by design?
If this is a bug can you tell me when/if it will be fixed?
If it is by design can you advise a way that I may be able to set/read the value if it is a decimal?

Thanks in advance.

Mark
Coordinator
Oct 13, 2008 at 2:19 PM
This is an oversight on my part. Should be present in next release.
I changed my Value property like this:
public virtual double Value
        {
            get
            {
                ValuePattern valuePattern = GetValuePattern();
                string value = valuePattern.Current.Value;
                return double.Parse(value);
            }
            set { GetValuePattern().SetValue(value.ToString()); }
        }
Oct 13, 2008 at 3:01 PM

Actually,  based on my limited knowledge and the investigating I’ve been doing since I posted the original message, I don’t think that will work either – sorry!

As far as can tell from using UI Spy the MS NumericUpDown control does not provide  the ValuePattern at all. It seems to provide the RangeValuePattern but then does not implement it correctly. For example, UI Spy always displayed a Minimum and Maximum of 0 and a value of 0, regardless of what was actually in the control itself.

In the end I resolved the problem by implementing the IRawElementProviderSimpler and IRangeValueProvider interfaces on my ‘spinner’ control (which extends the NumberUpDown control) and made sure I set all the properties correctly.

I could then access it via White by getting the corresponding UIItem and casting it’s AutomationElement to a RangeValuePattern.

It was a bit of a headache but I got there in the end.

From: viveksingh [mailto:notifications@codeplex.com]
Sent: 13 October 2008 15:20
To: Mark Beeton
Subject: Re: Spinner value = integer ? [white:37389]

From: viveksingh

This is an oversight on my part. Should be present in next release.
I changed my Value property like this:
public virtual double Value
{
get
{
ValuePattern valuePattern = GetValuePattern();
string value = valuePattern.Current.Value;
return double.Parse(value);
}
set { GetValuePattern().SetValue(value.ToString()); }
}

Read the full discussion online.

To add a post to this discussion, reply to this email (white@discussions.codeplex.com)

To start a new discussion for this project, email white@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Coordinator
Oct 16, 2008 at 8:54 AM
While you are right. But I think looking at UI Spy might not be providing the right picture.
Please download the source code and run the unit test for spinner.