Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid ActiveRow always returns 0
Message
From
14/05/2004 10:28:17
 
 
To
14/05/2004 09:51:50
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00904000
Message ID:
00904068
Views:
21
Hi Denis,

Whatever you're doing, it must be different from what I'm doing.

The nActiveRow is not as silly as it may seem. In the setfocus method This.AddPropery('nActiveRow',This.ActiveRow) is executed, so, when out of focus, it'll remember the active row.

Still, since it doesn't work it doesn't do much good.


>Hi again,
>I just did example with your code. ActiveRow is not 0 if in cmdDelete.Click() you do set focus on grid. In second example with TRY/CATCH you wrote wrong property name _grid1.nActiveRow. (must be ActiveRow). Well.. no problem on my machine with your code. Maybe you realy somewhere close cursor? no ideas
>
>Denis
>
>
>>Denis,
>>
>>Yes, I know.
>>
>>Which is exactly why I go through pains to set the focus to the grid.
>>
>>Isn't the idea of the grids setfocus method that the grid receives the focus?
>>
>>
>>>Hi
>>>ActiveRow returns zero if the grid doesn't have the focus or when you access a row outside the grid display.
>>>If you code in DeleteButton.Click() - then grid lost focus and focus go to DeleteButton and ActiveRow change value to 0.
>>>ActiveRow is not 0 just within Grid object
>>>
>>>Denis
>>>
>>>
>>>>Scenario: oForm.Pageframe.Page1.DeleteButton.Click
>>>>
>>>>This code produces error 52 in line 3, no table open in current work area
>>>>
>>>>
>>>>SELECT MyTable                           && Yes, it's open !!
>>>>THIS.PARENT._grid1.SETFOCUS              && Should ensure correct activerow
>>>>   IF THIS.PARENT._grid1.ActiveRow <> 0  && Error occurs
>>>>	DELETE
>>>>	THIS.PARENT._grid1.REFRESH
>>>>   ENDIF
>>>>
>>>>
>>>>So I tried
>>>>
>>>>
>>>>SELECT MyTable
>>>>TRY
>>>>  THIS.PARENT._grid1.SETFOCUS            && Add nActiveRow in setfocus
>>>>  IF THIS.PARENT._grid1.nActiveRow <> 0
>>>>	DELETE
>>>>	THIS.PARENT._grid1.REFRESH
>>>>  ENDIF
>>>>CATCH TO oException
>>>>ENDTRY
>>>>
>>>>
>>>>This does not produce an error, but on the other hand nothing happens, because the activerow is always zero.
>>>>
>>>>Why the grid has to have the focus in order to determine the activerow is quite beyond me, but that's another matter.
>>>>
>>>>It does make one wonder how the people who developed Excel, overcame this obstacle, and why this knowledge was not passed on to the VFP team.
>>>>
>>>>
>>>>TIA
Peter Pirker


Whosoever shall not fall by the sword or by famine, shall fall by pestilence, so why bother shaving?

(Woody Allen)
Previous
Reply
Map
View

Click here to load this message in the networking platform