[Gambas-user] A tricky requirement for SpinBox range : any ideas?
Tobias Boege
taboege at ...626...
Thu Dec 13 14:40:11 CET 2012
On Thu, 13 Dec 2012, Bruce wrote:
> The situation is:
>
> We either know that a particular horse was foaled (born) on or
> after year 2000 or we don't know which year it was foaled in,
> i.e. the value on the database for the foaled year is either
> something >=2000 or zero.
>
> The problem is:
> I am trying to use a spinbox to allow the user to enter the
> foaled year. To make it "easier" or "go faster" the minimum
> value of the spinbox should be 2000 and the maximum should be
> Year(Now()). But there is a requirement that if the horse's
> foaling date is not known then the user should be able to select
> 0 in the spinbox.
>
> Obviously, setting the spinbox minumum to 0 doesn't help when
> the foaling year is 2010 as they have to mouse wheel for a
> considerable time before setting it to a known value. I've
> tried using a checkbox next to the spinbox for "unknown" but it
> at best it looks messy (and the resultant code stinks).
>
They wouldn't have to wheel if they could _type_ ;-)
> By the way, I choose not use a date picker or a calendar control as the
> only data of interest is the year.
>
> As per the subject, anyone got any good ideas?
Let's face the truth: if you want to display "0" the [MinValue; MaxValue]
must include 0 as it would otherwise be rejected and you can't force any
text via the Text property or suchlike.
So I suggest MinValue = 0, MaxValue = Year(Now()) and this (hopefully not
too messy) code:
Public Sub SpinBox1_Change()
If SpinBox1.Value = 1999 Then
SpinBox1.Value = 0
Endif
If SpinBox1.Value And SpinBox1.Value < 2000 Then
SpinBox1.Value = 2000
Endif
End
But no, I don't know any cool trick...
Regards,
Tobi
More information about the User
mailing list