Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with spinner control.

Status
Not open for further replies.

mikemck7

Technical User
Dec 17, 2003
38
I'm trying to accomplish something with the spinner control (VFP8) that is making my head spin. I need the control to display increments of 10 but I also want the initial and lowest displayed value to be 1, not 0.

In other words the sequence displayed needs to be 1, 10, 20, 30 and so on. So basically the first upclick needs to imcrement by 9 and each one thereafter by 10. Therefore downclicking from 10 needs to decrement by 9 and display 1 in the control. I have 1 for keyboard and spinner low value properties. The high value property for both is 100 and the increment property is 10.

I hope this makes sense to someone out there. Thanks in advance.

Mike
 
Mike,

Off the top of my head and without any testing ....

In the Downclick event:

IF THIS.Value = 10
THIS.Increment = 9
ELSE
THIS.Increment = 10
ENDIF

and in the Upclick:

IF THIS.Value = 1
THIS.Increment = 9
ELSE
THIS.Increment = 10
ENDIF

I don't know if it will work, but it's worth a try.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

I've already tried something similar to that and it doesn't work because the spinner value is already changed and its the new number displayed by the time the up/downclick methods fire.

There ought to be a method that fires before the value and display are updated but I haven't found it yet.

Mike
 
I've already tried something similar to that and it doesn't work

Perhaps I'm misunderstanding your question but Mike's code works for me. If I set the spinner's initial value to 1 and its initial increment to 9 then I get the sequence 1, 10, 20, 30, 20, 10, 1 as I go up and down.

Geoff Franklin
 
Mike,

It works for me too. However, you do have to set an initial increment to match the initial value.

If you put this code in the Init:

this.value = 1
THIS.Increment = 9

along with the code shown above in the UpClick and DownClick, it should do just what you want.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Geoff and Mike,
You're right. I omitted "THIS.Increment = 9" in the INIT method. Thanks again,
Mike

 
Geoff and Mike,
I spoke too soon. At first it seemed to work when I added [blue]THIS.Increment = 9[/blue] to the INIT method. However when you spin down from 10 to 1 and spin up again, the value becomes 11. That's because the INIT method only tests once.

I solved the problem by removing that line from the INIT method and modifying the DOWNCLICK method which now looks like this:
Code:
	IF THIS.VALUE = 10 OR THIS.VALUE = 1
		THIS.INCREMENT = 9
	ELSE
		THIS.INCREMENT = 10
	ENDIF

Thanks again.

Mike
 
Hello,
It's been a long time so please help me refresh my mind. I created a form and put a grid, a text a command button
How can I refresh my grid so that after I click the command button, the only information that I can see are those equal to the value of the text I inputed. It's like if you put "apple" in the text, the grid will show only all the boxes with apple, and after you click "see all" button, the grid will show all boxes with different fruits.

Thank you
 
First, it's better to start a new thread when you have a new question rather than adding it to a thread on a different topic.

As for your question, it depends how you've constructed your grid. What's the RecordSourceType? For what you're doing, a parameterized view offers the easiest solution; you just have to requery the view.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top