Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Disappearing Grid
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00182897
Message ID:
00183098
Vues:
19
>>>>>>>>I have a formset and one form has a grid for browsing a file. At times I need to close the file and then reopen it again. Since the grid momentarily looses its data source, it disappears. Is there an easy way to recreate the grid? Right now I'm releasing the whole formset and recreating it again. All I need is just to get that one grid back. Do I need to hard code the grid in a routine and call the routine?
>>>>>>>>
>>>>>>>>Thanks,
>>>>>>>>Allen
>>>>>>>
>>>>>>>Allen,
>>>>>>>Edward's advice is valid and good, but from my experience not always necessary. Usually it is enough to unbind the grid temporarily, refresh your datasource, and the rebind the grid. Doing it this way, you won't lose any code in columns and controls, and any special formatting in the columns etc.
>>>>>If you first unbind the grid, and then kill and recreate its recordsource, the grid loses cotrolsource information, but retains column and control settings and code.
>>>>>
>>>>>Agree?
>>>>
>>>>This is simple test:
>>>>***Grid.Init event
>>>>this.recordsource="table1"
>>>>this.columncount=2
>>>>this.column1.controlsource="table1.id"
>>>>this.column2.controlsource="table1.cnt"
>>>>*** some Button.Click event
>>>>thisform.grid1.recordsource=""
>>>>thisform.grid1.recordsource="table1"
>>>>thisform.grid1.refresh
>>>>
>>>>After initialization grid shows 'id' (second field in table1) in the first column, and 'cnt' (first table field) in the second column. After button is clicked columns get reverted, i.e. column1 shows 'cnt' and column2 shows 'id'. So, should I agree with you or not? Probably not.
>>>
>>>This is what I stated.
>>>
>>>>>If you first unbind the grid, and then kill and recreate its recordsource, the grid loses cotrolsource information, but retains column and control settings and code.
>>>
>>>But try what you tested with
>>>
>>>WAIT WINDOW "Howdy World"
>>>
>>>in the click event of one of the text boxes in the grid. Without unbinding the grid before you USE IN and then USE the source table, the code dissappears.
>>
>>I understand what you mean but the example shows that even column settings are not preserved. I believe you agree that the situation when columns get reverted, and even worse with the same e.g. text.click code behind, is not only bad but also highly confusing. It would be better in this case to lose everything.
>
>Column settings, except the column's controlsource, ARE retained. That's what he's saying. Right Erik? (PMFJIA).

Rich, I have to retype now my initial reply which started all this:
"After data source reopening you should also restore grid recordsource and column.controlsources:
With Thisform.Grid
.Recordsource="mytable"
.Column1.Controlsource="mytable.myfield1"
.Column2.Controlsource="mytable.myfield2"
***
.Refresh
Endwith"
As you see, I suggested to reset exactly column controlsources. Regardless this evidency, I would also urge you to think what good in preserving everything except column controlsources? At best, someone doing this way will get some mess to clean up.
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform