J
jhonson999
Unregistered / Unconfirmed
GUEST, unregistred user!
土一点的办法,这样也行吧
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 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;