Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checkbox in grid clears grid - on {Enter} only
Message
From
22/03/2010 10:36:13
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
01456045
Message ID:
01456110
Views:
49
Yes, keypress. I'll look into it.

As to the kludge, imho, not really.
.nActiveRow 		= .ACTIVEROW
.LastActiveCell[1,1] 	= .ACTIVEROW
.LastActiveCell[1,2] 	= .ACTIVECOLUMN
.lLastRow = .ACTIVEROW= RECCOUNT(.RECORDSOURCE)
These are all needed in other parts of the program, to keep track of where the user's at, and to act accordingly.
FOR i = 1 TO .COLUMNCOUNT
        .COLUMNS(i).CONTROLSOURCE = .COLUMNS(i).CONTROLSOURCE
ENDFOR
.REFRESH
This, I believe is needed because I perceive(d) the grid as "temperamental" - it stems all the way back from sub-classing VFP5, does no harm, and I'm therefore inclined to keep it as is. Although I must say, now that I look at it again, the refresh is debatable.

The Try...Catch I've already explained - which leaves the SELECT and ALIAS() statements, which seem necessary because VFP under some conditions apparently sets column count to zero.

Anyway, thank you for your kindness and your help.

Peter

>My question is - do you have a button on this form that fires its Click method by pressing Enter (Default property of this button set to true).
>
>This whole code in ARCC seems like a big kludge solving this strange anomaly you can not figure out the cause.
>
>Alternatively, do you have a KeyPress event of the grid or form that may contribute to this behavior?
>
>>I'm not sure what you're asking?
>>
>>In the meantime I believe I've solved the problem by changing the AfterRowColChange method to this:
>>
>>
>>LPARAMETERS nColIndex
>>LOCAL i AS INTEGER, cAlias AS STRING
>>
>>* I've always felt that the grid control is a bit temperamental and found that setting the controlsource to itself 
>>* stabilizes it.  
>>
>>cAlias = ALIAS()    && added now
>>TRY
>>   WITH THIS
>>      SELECT(.RECORDSOURCE)   && added now
>>      .nActiveRow 			= .ACTIVEROW
>>      .LastActiveCell[1,1] 	= .ACTIVEROW
>>      .LastActiveCell[1,2] 	= .ACTIVECOLUMN
>>      .lLastRow = .ACTIVEROW= RECCOUNT(.RECORDSOURCE)
>>      FOR i = 1 TO .COLUMNCOUNT
>>         .COLUMNS(i).CONTROLSOURCE = .COLUMNS(i).CONTROLSOURCE
>>      ENDFOR
>>      .REFRESH
>>   ENDWITH
>>CATCH TO oEx
>>   oEx = NULL
>>ENDTRY
>>
>>* added next three lines now although I'm not sure they are needed as long as ALIAS() is not empty.
>>IF cAlias <> ''
>>   SELECT (cAlias)
>>ENDIF
>>
>>
>>
>>I'd appreciate your comments, if any.
>>
>>TIA
>>
>>Peter
>>
>>>>Hi Naomi,
>>>>
>>>>Thank's. Maybe your approach is the sounder one, although I can't offhand say why. I'll certainly give it a try.
>>>>
>>>>As to the try...catch, my thinking was that, if the replace, for whatever reason, were to cause an error, I don't want the whole app to fail.
>>>>
>>>>In the meantime I've narrowed the issue down: the enter on the checkbox for some reason causes the grids columncount to be set to zero. Why, I don't know.
>>>>
>>>Do you have a button on your form with Default property set to true?
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