Page 1 of 1

CRDBGrid -> How to catch click on sort column before sort?

Posted: Fri 18 May 2007 16:36
by pmatos
Hi!

How can I catch the click on the title column on a CRDBGrid with sort enabled, before sort is executed, so I can , under certain rules, cancel the sort?

Thanks.

Posted: Mon 21 May 2007 08:04
by Plash
The TCRDBGrid component doesn't have such feature. But you can edit its source code to add this feature. For example, add to TCRDBGrid a new event:

Code: Select all

type
  TBeforeSort = procedure(Sender: TObject; Column: TColumn; var EnableSort: boolean) of object;
Then call this event handler from the MouseUp method of TCRDBGrid.

Code: Select all

...
          if TCRColumn(Column).CanBeSorted and (dgeEnableSort in OptionsEx)
            and MouseInLowerstLevel(X,Y,Column) and (LastBtn = Column.Index)
          then begin
            SortEnabled := True;
            if Assigned(FBeforeSort) then
              FBeforeSort(Self, Column, SortEnabled);
            if SortEnabled then begin
...

Posted: Mon 21 May 2007 10:44
by pmatos
Do you have any plans to include such feature in a future version?

Posted: Mon 21 May 2007 11:12
by Plash
CRControls components are no longer supported by Core Lab. So we do not plan to add such feature to TCRDBGrid.