General information
Category:
Coding, syntax & commands
>>Greetings All
>>I have created a grid subclass that includes a custom method to sort on a columns control source when the user clicks on the grid header. The method simply checks for the existence of an index key expression on the field selected, and if the key exists, sets the order of the grid's resordsource with a SET ORDER TO. The method works fine, however, an unfortunate behavior was that the row selected in the grid prior to clicking on the column header and calling the method was no longer the selected row after the grid was re-ordered. I am not moving the record pointer in the sort method and verified that RECNO() was the same before and after re-ordering. However, the grid's ActiveRow property would be changed. I have eliminated this behavior by adding code to the sort method to set the focus off the grid, prior to issuing the SET ORDER TO command, and then re-setting the focus to the grid with This.SetFocus(). Can anyone explain to me why this is necessary? I have seen several references
>>already to situations where things don't behave as expected if the focus happens to be on a grid. Can anyone give me some insight regarding special circumstances pertaining to grids? Under what conditions is it necessary to move the focus off the grid in code in order to accomplish something, or what 'strange' behaviors can occur simply by having the focus in a grid. I would also appreciate code examples for sorting a grid by clicking on the column header.
>>Thanks In Advance
>>Bill Sabo
>
>Hello Bill,
>
>in some cases like that can help to set ThisForm.LockScreen = .T., Set orders
>and set back ThisForm.LockScreen = .F.
>
>Petr Valach
Hello Petr,
Thanks for the advice. I'll try leaving the focus on the grid, and locking the screen instead.
Bill
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only