Hackers Guide to Visual FoxPro 7.0
KeyboardHighValue, KeyboardLowValue, SpinnerHighValue, SpinnerLowValue
These properties determine what values you can enter in a spinner using either the keyboard or the arrow buttons.| Usage | spnSpinner.KeyboardHighValue = nValue nValue = spnSpinner.KeyboardHighValue spnSpinner.KeyboardLowValue = nValue nValue = spnSpinner.KeyboardLowValue spnSpinner.SpinnerHighValue = nValue nValue = spnSpinner.SpinnerHighValue spnSpinner.SpinnerLowValue = nValue nValue = spnSpinner.SpinnerLowValue |
| | Although they ultimately control the same thing (the maximum value the user can enter in the spinner), KeyboardHighValue has a lower maximum value than SpinnerHighValue: 2,147,483,647 versus who knows how high (we gave up after entering values up to 1.0 E+100). Assigning a value greater than 2,147,483,647 to KeyboardHighValue results in it being set to a negative number. Assigning an enormously high value to SpinnerHighValue doesn't mean you'll be able to spin up to a value that high. First, who'd have the patience? Second, because of the inherent limits in numeric precision, you'll lose the values in the rightmost digits (they'll appear to be there but when you access the spinner's Value, you'll end up with something like a number in scientific notation). |
Spinners in Visual FoxPro are much better than those in FoxPro 2.x. You can change any of these properties (as well as Increment) on the fly, so a spinner's range can change during a program. The only thing you can't do, to our regret, is set up what we guess should be called DynamicSpinnerHighValue, and so forth. That is, you can't assign a variable to one of these properties and have it changed dynamically—when the variable changes, you need to reassign the spinner property.
Figure 1 shows a form containing a date spinner class, DateSpin, based on the Container class. The range for the day spinner (the one in the middle—this uses American dates) changes based on the month and year chosen with the other spinners.Figure 1: Date Spinner—One spinner controls another.
The LostFocus methods for the month and year spinners each call a custom method of the container, FixDays, to update the day spinner's properties, as follows:| Example | * FixDays DO CASE CASE INLIST(This.nMonth, 1, 3, 5, 7, 8, 10, 12) This.spnDays.SpinnerHighValue = 31 This.spnDays.KeyboardHighValue = 31 CASE INLIST(This.nMonth, 4, 6, 9, 11) This.spnDays.SpinnerHighValue = 30 This.spnDays.KeyboardHighValue = 30 CASE This.nMonth = 2 IF This.LeapYear(This.nYear) This.spnDays.SpinnerHighValue = 29 This.spnDays.KeyboardHighValue = 29 ELSE This.spnDays.SpinnerHighValue = 28 This.spnDays.KeyboardHighValue = 28 ENDIF ENDCASE IF This.nDay > This.spnDays.SpinnerHighValue This.nDay = This.spnDays.SpinnerHighValue ENDIF |
| See Also | Increment, RangeHigh, RangeLow |
View Updates
Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.
Категории