关于DBGrid1中的排序问题(30分)

  • 主题发起人 主题发起人 zhoubbss
  • 开始时间 开始时间
土一点的办法,这样也行吧
procedure TForm_main.DBGrid_topTitleClick(Column: TColumn);
var
lInteger_count,lInteger_Length:integer;
lString_All,lString_Last:string;
begin
for lInteger_count := 0 to dbgrid_top.FieldCount - 1 do
begin
lInteger_Length := length(dbgrid_top.columns[lInteger_count].Title.Caption);
lString_Last := copy(dbgrid_top.columns[lInteger_count].Title.Caption,lInteger_Length-2,3);
lString_All := copy(dbgrid_top.columns[lInteger_count].Title.Caption,1,lInteger_Length-3);
if dbgrid_top.columns[lInteger_count].FieldName = column.FieldName then
begin
if (lString_Last = ' ▼') then
begin
adoquery_main.Sort := column.FieldName + ' ASC';
dbgrid_top.columns[lInteger_count].Title.Caption := lString_All + ' ▲';
end
else if (lString_Last = ' ▲') then
begin
adoquery_main.Sort := column.FieldName + ' DESC';
dbgrid_top.columns[lInteger_count].Title.Caption := lString_All + ' ▼';
end
else
begin
adoquery_main.Sort := column.FieldName + ' ASC';
dbgrid_top.columns[lInteger_count].Title.Caption := lString_All + lString_Last + ' ▲';
end;
end
else
begin
if ((lString_Last = ' ▼') or (lString_Last = ' ▲')) then
dbgrid_top.columns[lInteger_count].Title.Caption := lString_All;
end;
end;
end;
 
没有这么麻烦吧?
procedure Tfrm.DBGridEh1TitleClick(Column: TColumnEh);
begin
ADOQuery1.Sort:=Column.Field.FieldName;
end;
我只用这样就可以了
 
你们真无聊
 
后退
顶部