Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Load Order of records in the .SCX
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00085824
Message ID:
00085841
Views:
30
>>Does anyone know what controls the load order of items in a class?
>>
>>I have a class based on a container with two controls in it. In the .VCX the record for control #1 appears before the record for control #2, but the init event for control #2 is executing before the init event for control #1. Any idea what would cause this?
>Leighton,
>
>The creation order is controlled by the z-order of the controls, that is their position in the depth axis of the container.
>
>If you were to place the controls on top of each other one of them would in front of the other. The one in back is created before the one in front.
>
>You can control this by selecting the control you want created first and choosing Brign To Front from the Format menu, then do the same for the seond one and the third one etc. until you ahve been through them all. Once you have done this one you brought to front first will be the backmost one and so on.
>
>Now that I have told how to set the creation order to be what you want, I will tell you that if there is a dependency on the creation order of the contained objects then thee is a serious design flaw in your class. Perhpas you can tell us why the creation order is important to you and we could suggest an alternative approach that would not be dependent on the creation order.


I know that this was terrible design and wasn't going to leave it like that. I just wanted to see if it was going to work and stumbled across the fact that controls are not loaded in the order they are listed in the table.

I tried bringing the control I wanted loaded first to the front with no change in behavior. What I really need is a LOAD event for the class but there isn't one.

Here is what I'm trying to do. I have a basic two column picklist class: two list boxes, Available and Selected, and four buttons, add one, add all ... The list boxes display records from the same table, but are filtered based on the contents of the SELECTED field. In the INIT method of each listbox I have the following code:


local cAlias
cAlias = substr(sys(2015), 3, 10)

use (this.parent.TableAlias) again in 0 alias (cAlias)
this.rowsource = cAlias

select (this.rowsource)
set filter to ! SELECTED


In the INIT of the container on the form I have:


local cAlias
cAlias = substr(sys(2015), 3, 10)

select ;
LASTNAME, ;
FIRSTNAME, ;
MIDDLENAME, ;
PROVIDERID, ;
.f. as SELECTED ;
from PROVIDER ;
order by 1, 2, 3 ;
into table (cAlias)

this.TableAlias = cAlias


The problem is the INIT in the controls are executed before the INIT in the container.

The only two solutions (virtually the same) I can think of are:

1. Move the listbox INIT code into the INIT event of the container in the class definition and execute a DODEFAULT() after running the INIT code above.

2. Add a custom method to the class which sets the listbox rowsource after the INIT code above runs.

I was hoping the keep the code more segmented.

Any help you can give is much appreciated.

Thanks, Leighton
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform