Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Rey Magdalaga
  Where is Rey Magdalaga?
 Rizal Province
 Philippines
 Rey Magdalaga
 To: Labu Labi
  Where is Labu Labi?
 Negeri
 Malaysia
 Labu Labi
 Tags
Subject: RE: Disable certain rows in a grid
Thread ID: 104326 Message ID: 104331 # Views: 1 # Ratings: 0
Version: Visual FoxPro 8 Category: Grids
Date: Tuesday, August 15, 2006 8:01:14 AM         
   


> Hi guys,
>
> I wonder if we can disable certain rows in a grid? Let's say I have a grid with 10 records (rows). How to disable certain rows based on their values, eg. disable any rows having odd numbers?
>
> ~Labu
> All you have to do is search and ask!


Hi Labu,


You can put a code to disable the objects of each column in the grid on the AFTERROWCOLCHANGE event of the grid.

So as per your example;
*** in the AfterRowColChange of the grid

****************************************************
LOCAL ll_Value, nCols, nControls, oControl

IF MOD(RECNO(),2)>0
*** ODD
ll_Value = .F.
ELSE
ll_Value = .T.
ENDIF

FOR nCols=1 TO This.ColumnCount
IF This.Columns(nCols).ControlCount > 0
FOR nControls = 1 TO This.Columns(nCols).ControlCount
oControl = This.Columns(nCols).Controls(nControls)
IF oControl.BaseClass # 'Header' && no need for headers
oControl.Readonly = !ll_Value
ENDIF
ENDFOR
ENDIF
ENDFOR

RETURN

*******************************

The display of the disabled records, you can do that using the column's Dynamic properties. I choose Readonly to enable you to navigate on the records but not edit them. You can change it to Enabled and remove the ! to totally deny access on the record.

Regards,

ReyM

ENTIRE THREAD

Disable certain rows in a grid Posted by Labu labi @ 8/15/2006 6:56:38 AM
RE: Disable certain rows in a grid Posted by Bernard Bout @ 8/15/2006 7:49:55 AM
RE: Disable certain rows in a grid Posted by Rey Magdalaga @ 8/15/2006 8:01:14 AM
RE: Disable certain rows in a grid Posted by Andy Kramek @ 8/15/2006 12:45:43 PM
RE: Disable certain rows in a grid Posted by Marcia Akins @ 8/15/2006 4:24:52 PM
RE: Disable certain rows in a grid Posted by Labu labi @ 8/16/2006 7:18:42 AM