Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Set Page Frame Controls Properties Programataically
Message
From
27/12/2018 12:03:01
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01664888
Message ID:
01664891
Views:
52
>Am building a Form with a Page Frame with many Pages with each Page containing multiple Controls. Due to the sheer number of controls I would like to set Control Properties programatically (have a table).
>
>How best to accomplish this?

For slow loading of a form, that contains a PageFrame with many pages and\or controls within, the recommended trick is to keep a page's content as a class and instantiate on demand (if that page is activated at all).

Apart from that, this is from my real world codes where I set the sources of controls in pages at runtime from an object array (you can think that as a cursor):
* within thisform.LoadPages method - called on init and whenever the contents of controls are saved to refresh

* some preparation codes 
With This.pgfConfig
	With .pgWelcomeScreenOptions && Sign-In page
		* Welcome message, announcement box, 2 chkboxes and 1 drop-down
		This.SetSource(.chkShow,REC_GEN_MSG,'IsActive')
...
Here is the SetSource method to better understand:
 * SetSource method
Lparameters toObject, tnItemId, tcRecField

* Some internal check here that is irrelevant for general use

m.toObject.ControlSource = 'thisform.oConfig.Option['+str(m.tnItemId)+'].'+m.tcRecField
Here, we are instructing to set the ControlSource of Thisform.pgfConfig.pgWelcomeScreenOptions.chkShow to our object array's REC_GEN_MSG row (an integer constant), IsActive member.
Object array looks like a table (really is loaded from a table - named oConfig and is an array property of the form:

generated from a table that has: IsActive, IntVal, cVal, ... fields
If, say, REC_GEN_MSG is 5 this means we are setting that table's recNo: 5 row's IsActive field as the controlSource (normally you use ControlSource like alias.field, here I use it as arrRecords[RecordNumber].Field - allows me to control a whole table).

Anyway, that array controlSource thing is an extra trick, the part that is related to your question is directly the SetSource method itself that you can modify as you see fit.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform