DBGRIDEH in the three-layer structure Realization Click Column Title Sort

zhaozj2021-02-16  106

At First You NEED TO Define Index for Every Column That You Want To Sort:

1W: in IDE

Double Click Your ClientDataSet's Indexdefs Property, Add New, Set "Name" "Fields" "Descfields" Value (for Example: Equal to Column Name)

2W: in Code

With dataset.indexdefs do begin clear; with addindexdef do beg, name: = 'Your column name; fields: =' Your column name '; descfields: =' Your column name '; end;

THEN WRITE CODE IN DBGRIDEH ONTITLECLICK:

case Column.Title.SortMarker of smNoneEh: begin Column.Title.SortMarker: = smDownEh; fTagStateSetDM.cdsData.IndexName: = Column.FieldName; end; smDownEh: begin Column.Title.SortMarker: = smUpEh; fTagStateSetDM.cdsData.IndexFieldNames: = Column.fieldName; End; Smupeh: Begin Column.Title.Sortmarker: = smdowne; ftagstatesetdm.cdsdata.indexName: = column.fieldname; end;

转载请注明原文地址:https://www.9cbs.com/read-10427.html

New Post(0)