Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Container in a grid
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00496243
Message ID:
00496588
Vues:
8
Hi Nadya
Please go throu the FAQ u told me to write ..

* FAQ start ->

Hello there.

I am sure many a times VFP users have felt the need to put a Container control in a grid control or maybe show an image in the grid column. All this works fine but what if you wanted to change properties of a control in the container depending on conditions in the underlying table.

Let's take an example.
We have a table with the following structure ..

tblProducts
-------------------
cName C(30)
nCode N(5)
mDescription (Memo)

We are displaying this data in a grid via a Container with some controls on them.
2 TextBoxes and 1 Command Button
The requirement is to enable/disable the Command Button if there is data in the memo field. Simply put we want to do this ..

if Empty(MemoField)
CommandButton.enabled = .f.
else
CommandButton.enabled = .t.
endif

This applys to all records in the table and so to the Container in the grid. Every row in the grid will have a different state of the CommandButton depending on the row in the table from where the data is comming.

In a normal situation one could put code in the refresh event of the command button of the control but that does not work.

A workaround is to call a function for each row and update the CommandButton's state accordingly.

We can do so by setting the DynamicBackColor property to a Function in a form.
In our exampl we can set the Grid.Column1.DynamicBackColor property to =Thisform.DummyFunction()

The code in the DummyFunction would look something like this

* DummyFunction()
If empty(Table.MemoField)
Thisform.Grid.Column1.Container.CommandButton.Enabled = .F.
else
Thisform.Grid.Column1.Container.CommandButton.Enabled = .T.
EndIf

That' all there is to it.

--------------- or --------------

According to Larry suggestion .....

* Larry Miller UT Id #030732
* Bifrost Solutions
* Odenton, Maryland


The Refresh method of the Grid, does not propagate like the Refresh method of a form. You could the following functionality to your grid to correct this "flaw".
local lxx, oControl
With THIS
For lxx = 1 to .ColumnCount
oControl = Eval(".Columns[lxx]."+.Columns[lxx].CurrentControl)
if pemstatus(oControl,'Refresh',5) then
oControl.Refresh()
endif
Endfor
Endwith
Add the code to the Refresh method of the grid. It will go through and call the Refresh methods of all currentcontrols. If more than one control is in a column, the non-active one doesn't get updated. You could change this if you like.

That's all folks ..!

* FAQ End <-
Regards
Hiten K M

( The best and the worst are yet to come .. keep coding ! )

My Resume >>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform