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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Spinner to select a Container 2

Status
Not open for further replies.

David Higgs

Programmer
May 6, 2012
390
GB
My Form displays a "Container" with Textboxes for inputting data. I would like to have a selection of Containers offering a variation of Textboxes but only displaying one Container at a time. I'm thinking along the lines of using a "Spinner" to scroll through the various Container options and making the Container visible or Hidden depending on selection.

I am not sure how I would achieve the above, any help would be much appreciated.

Regards,

David.

Recreational Developer / End User of VFP.
 
David, are you sure you want a spinner to do that? In general, a spinner is used for inputting a numeric value from a limited range. From your description, that is not what you want to achieve.

If I have understood it right, you want to place your textboxes in several groups. You want to give the user some method of selecting a group. Once the user has made that selection, you want only that group to be visible. Have I understood that right?

If so, you need a pageframe. Place each group of textboxes (and any other relevant controls, such as labels) on a separate page of the pageframe. Use the Tabs property to hide the tabs.

Then create a control which programmatically makes the required page visible. One way of doing that would be to use a combo box. Each item in the combo corresponds to one of the pages. In the combo's InteractiveChange, set the pageframe's ActivePage to the relevant page number.

As an alternative to a combo box, you could use an option group, or possibly some other method.

Apologies if I have misunderstood your requirements.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike Lewis said:
David, are you sure you want a spinner to do that?

My thoughts were to use just the up/Down Arrows (enlarged, Height = 100) of the Spinner ignoring the Number option by reducing the width of the Spinner. I would then place the Up/Down Arrows at the end of the Container and use it to scroll through the various containers (probably less than 6) until the desired Container is showing. In the Up/Down Click I would have Code to Display or Hide each Container.

If I have understood it right, you want to place your textboxes in several groups. You want to give the user some method of selecting a group. Once the user has made that selection, you want only that group to be visible. Have I understood that right?

Yes you have. I currently only have a Single Container of Text Boxes and want to provide a selection of containers with different Textbox options

You given me food for thought on other options which I need to evaluate.

P.S I should have mentioned that besides the "Container" there are several other items on the Form including a couple of Grids. The Form is used to Input Data and Display Data.

Regards,

David.

Recreational Developer / End User of VFP.
 
I guess you could do it with a spinner. In the InteractiveChange, you could increment or decrement the pageframe's ActivePage property (always making sure that the user cannot go beyond the number of pages). But it wouldn't be my first choice.

A better option might be to provide two buttons: one to move forward through the pages, and one to move back. In that case, the relevant page would be activated in the Click events. You could perhaps display an arrow or something similar on each button to indicate the direction of travel.

Or, you could use an option group, with its Style property set to 1 (graphical), and show an icon for each option to indicate the corresponding page.

This is largely a matter of what you think would look best. The main point of my post is that you should use a pageframe rather than a set of containers to let the user easily switch between the groups.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi David,

I second Mike's idea to use pageframes. I've been working with pageframes and nested pageframes for years with and mostly without visible tabs.

For example ~15years ago I was experimenting with eztwain for scanning integration in an app called 'collection folders'.
There is a master pageframe that has a page for file selections (to add them to a collection), general configuration options (like M$ apps for OLE integration of XLS and DOC files) and a page for displaying the various files like txt, jpg/bmp/gif/png, doc, xls, pdf a.s.o.
Now, this 'display/viewer' page holds another pageframe with pages for displaying individual filetypes, depending on availability of M$ office apps, web browsers, pic viewers.
The activation of the master pages happens by clicking on a button in the forms ribbon
The activation of the subpages depend on the selected file(filetype) within a collection that also activate the master page if it issn't active.
The file collection is outside the master pageframe. It is positioned on the forms left side.
The masterpage that holds the sub-pageframe has two areas. The left part shows fileinfos like create date, bytes, assign date, inputfield for a filename change, date of last edit.

So, what am I using for switching the pages:

1. ribbon page changes that switch to different master pages
2. buttons in the form ribbon for switching master pages
3. listbox selection to switch pages in the sub pageframe and the master pageframe

Our customers are working with this for 15 years now and noone ever had problems with using the app and without programming knowledge noone will assume pageframes in this app. Its simply a fluent integration of something that is designed for such a kind of programming and visual interface.

If you use this approach, it won't last long and you will love the concept of working this way :)

JM2C



-Tom
 
Mike Lewis said:
If so, you need a pageframe. Place each group of textboxes (and any other relevant controls, such as labels) on a separate page of the pageframe. Use the Tabs property to hide the tabs.

Having tried your suggestion of using Pageframes I can see now that is the way to go. I'd not considered using Pageframes without Tabs before, interesting idea. I just need to sort out a means of switching between pages. I favour the Up / Down Arrow Option using a Command Group, although I will continue evaluating other options.

Tom Borgmann said:
If you use this approach, it won't last long and you will love the concept of working this way :)

Thank you for your input; now that the mist has cleared I can see that Pageframes are the way to go. I will take a look at your suggestions for activating the various pages.



Regards,

David.

Recreational Developer / End User of VFP.
 
Glad to have been able to help, David. Like Tom, I have been using pageframes without tabs for a long time. I tend to use a graphical option group as the switching mechanism. With a bit of effort, you can get really creative with it. But the up-down arrow / command group approach is also good.

Let us know if you run into any problems.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
So, I now have a Pageframe with 4 Pages (No Tabs) and up/down Buttons to scroll through the Pages.

Each Page has a common Textbox called Contest_Callsign.

My question is, if I use the following Code to display the Contest_Callsign whilst Page1 is active, the contents will be displayed ok.

Now if I was to Scroll to make Page2 the active Page the code will still display the Contest_Callsign of Page1. How would I modify the code to show the Contest_Callsign of the Active Page?

For Test Purposes the following code is in a Command Button on the Main Form.

Code:
test = thisform.pF_Contest_Exchange.Page1.Contest_Callsign.value
MESSAGEBOX(test)

Regards,

David.

Recreational Developer / End User of VFP.
 
David, your code always displays the contents of the call sign on Page 1 because you have hard-code ".Page1" in the code:
Code:
test = thisform.pF_Contest_Exchange.[highlight #EDD400]Page1[/highlight].Contest_Callsign.value
MESSAGEBOX(test)

If you change that to .ActivePage, it will work as desired:

Code:
test = thisform.pF_Contest_Exchange.[highlight #EDD400]ActivePage[/highlight].Contest_Callsign.value
MESSAGEBOX(test
)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hello Mike,

I've tried several things to make this work, including ActivePage which produces a "Unknown member ActivePage." error.

Regards,

David.

Recreational Developer / End User of VFP.
 
David,

Oh, heck. This my fault. I was thinking that ActivePage returns an object reference to the active page. In fact, it returns the number of the active page. Silly me.

So I would think you need this:

Code:
test = thisform.pF_Contest_Exchange.[highlight #EDD400]Pages(ActivePage)[/highlight].Contest_Callsign.value

Try it and report back.

By the way, that might give an incorrect result if you prgrammatically change the order of the pages, but I'm pretty sure you won't be doing that.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hello Mike,

Thank you for your replies.

I have been scooting around the problem all day, so near yet so far away.

The following code works a treat.

Code:
P_Number = thisform.pF_Contest_Exchange.ActivePage
test = thisform.pF_Contest_Exchange.Pages(P_Number).Contest_Callsign.value



Regards,

David.

Recreational Developer / End User of VFP.
 
Hi David and Mike,
it would indeed be nice, if we could make use of ActivePage as a direkt reference to the active Page. As this isn't possible, the use of WITH ... ENDWITH makes a lot of sense if you want to shorten the code.

Code:
* // Version 1 - Using complete references
test = thisform.pF_Contest_Exchange.Pages(thisform.pF_Contest_Exchange.ActivePage).Contest_Callsign.value 

* // Version 2 - using a variable
P_Number = thisform.pF_Contest_Exchange.ActivePage
test = thisform.pF_Contest_Exchange.Pages(P_Number).Contest_Callsign.value 

* // Version 3 - Using WITH...ENDWITH
WITH thisform.pF_Contest_Exchange
     test = .Pages(.ActivePage).Contest_Callsign.value 
ENDWITH

I usually use the WITH...ENDWITH command, as my object hierarchies are more layered and can be shortened significantly by using that command.

-Tom
 
Hello Tom,

Thank you for sharing the alternative options, always nice to see.

Regards,

David.

Recreational Developer / End User of VFP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top