用enlib控件DBGridEh
怎样使表格具有按title button排序的功能?
在ucommon中添加
procedure MakeDBGridEhSort(qry:TQuery;Column:TColumnEh);
var
i: Integer;
strsql: string;
begin
//平,降,升,降,升
if not qry.Active then
begin
exit;
end;
strsql:=qry.SQL.Text;
i:= pos('order by', strsql);
if i>0 then strsql:= copy(strsql, 1, i-1);
case Column.Title.SortMarker of
smUpEh: begin
strsql:= strsql + ' order by ' + Column.FieldName + ' DESC';
end;
smDownEh: begin
strsql:= strsql + ' order by ' + Column.FieldName + ' ASC';
end;
smNoneEh: begin
strsql:= strsql + ' order by ' + Column.FieldName + ' DESC';
end;
end;
with qry do
begin
Active:= False;
SQL.Clear;
SQL.Add(strsql);
Active:= True;
end; // with
end;
双击表格,把TDBGridEh对象中各个button的title|titlebutton属性设为true
选中表格,添加OnTitleBtnClick事件,在其中添加
ucommon.MakeDBGridEhSort(DM.qryCJGL,Column);