Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combo/Dropdown List
Message
De
21/08/1998 17:54:58
 
 
À
21/08/1998 16:13:36
Bill Breay
Custom Business Software
Arvada, Colorado, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00128666
Message ID:
00128957
Vues:
21
Bear with me as I am still on the steep part of the learning curve with VFP5. I am an old Cobol XBase fox 2.6 programmer.

After looking at your suggestions I think some more detail is in order. The rowsource array is created when the app is started and is used by other forms and even other pages in this particular form.

The combobox is set up as

Boundcolumn 2
Bound To .T.
Column Count 1
ControlSource table field name
First Element 1
RowSource Array name
Style 5

The combobox shows the namefrom first col of array and the table carries the id code from the second column.

This array is used in other pages of this multi page pageframe.

(This is a repost to correct typos, sorry)

I have done a 'set step on' in the init and in the load of the form and in both cases the value of the table has already been changed.

I also tried to programatically change the controlsource from the activate of the page and that did not work because the value in the table had already changed.

I also did a breakpoint for the value of the field to stop when changed and the location of the stop was at the init of the combobox even though I have no code in that area.

Bill,

Well, us old cobol, xBase guys have to stick together, otherwise these young, smarter, better looking, OOPS VFP whippersnappers will code rings around us.

At what point do you move your record pointer to the desired record in the controlsource table? Presumably during the INIT() of the form. At this point your combobox already has a value -- the first item in the rowsource array.

Let's take care of that problem first. You are setting properties in the PEM manager as follows:
     rowsource = myGlobalArray
     rowsourcetype = 5
When the combobox is init()ed, it assigned myGlobalArry as its rowsource and reads the first item in myGloblaArray as its value. This, unhappily, is how it usually works. The workaround is not to set the rowsource until the init() of the object, after its value has already been refresh()ed. Something like this:
*-- myComboBoxObject.Init()

IF DODEFAULT()
    WITH this
        .rowsource = myGlobalArray
        .rowsourcetype = 5
    ENDWITH
ENDIF

RETURN
A .requery() should not be necessary since each time you assign a new rowsource, a requery() is automatically issued.

This code should prevent the first element of the array from being assigned as the value of the control. The value should now be the value of the assigned field in the first record of the controlsource.

When you then move the controlsource table pointer to the correct record and refresh(), the right value should be assigned to the control When do you Refresh() the page the combobox is on? This should refresh the combobox value so that the correct value is shown. Remember, refreshing a form does not automatically refresh any control on a page on the form. You have to force a page refresh using code in the pageframe something like:
*-- MyAbstractPageFrame:Refresh()

IF DODEFAULT()
    LOCAL i
    FOR i = 1 TO .pagecount
        .pages[i].refresh()
    ENDFOR
ENDIF

RETURN
This will refresh every control on every page of the pageframe.

If you are moving the controlsource table pointer to the correct record and refreshing the control properly and the combobox value is still wrong, then my solution would be to blank out the combobox's controlsource until the control is INIT()ed. That way, when combobox.init() tries to assign a value to the control there is no controlsource, and no value is assigned.

To do this, first set the controlsource in the PEM manager to blank. In the INIT() method of the combobox, put the following AFTER the call to the superclass of the control.
*-- myAbstractComboDropBox.Init()

IF DODEFAULT()
    NODEFAULT && Since Default has already run
    this.controlsource = "myControlSourceTable.myControlSourceField"
    .refresh()
ENDIF

RETURN
I do not think your code is the problem (I presume you have rowsourcetype set to 5, array -- since your rowsource appears to be working properly). You are just caught in the usual problem of trying to figure out when events occur -- which is sometimes difficult since they occur inside black boxes and you cannot follow them in the code like you used to be able to do in the pre-OOPS days. And M$ is most unhelpful since the documentation for VFP DOES NOT usually describe the default behavior of an event handler -- a very serious omission imho.

Another old Indian trick I use is to initially set all tables in the data environment to EOF(). That was all controls linked to a control source are disabled and the user is forced to select a record before he can take any action. This also has the effect of preventing any unwanted value assignments since a disabled control will not refresh() or will refresh() to blank. You can set all tables to EOF() in the init() of the form.

Try something like the above, and see what happens. I'm pretty sure that one approach or the other will cure the problem.

Give a hollar if is does not work.

regards,
Jim Edgar
Jurix Data Corporation
jmedgar@yahoo.com

No trees were destroyed in sending this message. However, a large number of electrons were diverted from their ordinary activities and terribly inconvenienced.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform