Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid - row and column information about active cell
Message
From
28/10/2003 13:07:18
 
 
To
28/10/2003 08:54:32
Metin Emre
Ozcom Bilgisayar Ltd.
Istanbul, Turkey
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00843489
Message ID:
00843647
Views:
27
Hello Metin,

There are two grid properties, ActiveRow and ActiveColumn that may be what you are looking for. Be careful of these, however, they are not robust, and if the grid does not have current focus, or the grid cell with active focus is outside the visible portion of the grid, these may show unexpected values. These are properties that the grid uses for its own purposes, and those purposes may not be the same as ours.

Rather than relying on these properties to find out the location of the current active cell in the grid, create your own properties.

In the Init() of the grid, add the following code:
*   MyGrid.Init()
*
IF DODEFAULT()
   
   WITH this

      .AddProperty( "CurrentActiveRow", .ActiveRow )
      .AddProperty( "CurrentActiveColumn", .ActiveColumn )

   ENDWITH

   RETURN .T.

ENDIF

RETURN .F.
In the AfterRowColChange() event, add this code,
*   MyGrid.AfterRowColChange()
*
LPARAMETERS nColIndex

WITH this

   .CurrentActiveRow    = RECNO( .RecordSource )
   .CurrentActiveColumn = nColIndex

ENDWITH

RETURN
One warning. The nColIndex integer parameter, despite its name, is not an index into anything. It describes the order in which the column appears in the grid (display order), not the order in which the column appears in the Columns[] collection (index order). If your columns may be reordered at runtime, you will have to do additional work to convert CurrentActiveColumn into an index into the Columns[] collection.

If you need help with that, let me know.

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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform