Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unbound Checkbox in a Grid?
Message
De
05/04/2006 21:20:25
 
 
À
04/04/2006 21:42:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 8
OS:
Windows 2000
Database:
Visual FoxPro
Divers
Thread ID:
01110469
Message ID:
01110836
Vues:
19
Thanks for the response. Judging by your answer, it sounds like unbound checkboxes in a grid tied to a table just don't work, which confirms my own experience trying to get it to work. I was hoping to avoid using a cursor because I have several filter and sort options that allow the user to view only certain records and/or change the order in which they are displayed. As the underlying table grows, which I know it will, the form's refresh will bog down significantly if I have to rebuild the cursor everytime. Views, I think, would present a similar problem. I found a thread this afternoon that has provided the answer (ThreadID #1103071, MessageID #1103178) using the DynamicCurrentControl property of a grid column. Since I had already added a logical field to my underlying table, I used the column bound to that field for this operation. I created 2 command button classes, one with a check mark image, one without. The CommandUnChecked has the following code in the click() method:
this.parent.parent.aSelected[recno(this.parent.parent.recordsource)] = .t.
thisform.Refresh()
The CommandChecked has the following code in the click() method:
this.parent.parent.aSelected[recno(this.parent.parent.recordsource)] = .f.
thisform.Refresh()
I then added the following code to the grid's init method:
this.addproperty("aSelected[1]")
DIMENSION this.aSelected(reccount(this.recordsource))
this.aSelected = .f.
WITH this.columns(1)
   .AddObject('cmdChecked1', 'CommandChecked')
   .AddObject('cmdUnChecked1', 'CommandUnChecked')
   .currentcontrol = 'cmdUnChecked1'
   .cmdUnChecked1.visible = .t.
   .cmdChecked1.visible = .t.
   .sparse = .f.
   .DynamicCurrentControl=;
   [iif(this.aSelected(recno()), "cmdChecked1", "cmdUnChecked1")]
ENDWITH
When I run the form and click the button, the array gets updated, the visible button gets switched, and the underlying table is unchanged. Now I just need to add code that updates the array when records get added or deleted...Thanks again.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform