首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

dbgrid 怎么实现排序箭头(三角的)

2012-03-27 
dbgrid 如何实现排序箭头(三角的)dbgrid 如何实现排序箭头(三角的)[解决办法]首先申明是从网上贴的(原来粘

dbgrid 如何实现排序箭头(三角的)
dbgrid 如何实现排序箭头(三角的)

[解决办法]
首先申明是从网上贴的(原来粘下来的,不知道原创人了:( ),不是原创,呵呵,

Delphi(Pascal) code
procedure TForm1.DBGrid1TitleClick(Column: TColumn);var temp, title: string;begin temp := Column.FieldName; qusp.Close; if Column.Index <> lastcolumn then begin   if (Pos('↑', DBGrid1.Columns[LastColumn].Title.Caption) > 0) or (Pos('↓', DBGrid1.Columns[LastColumn].Title.Caption) > 0) then     DBGrid1.Columns[LastColumn].Title.Caption := Copy(DBGrid1.Columns[LastColumn].Title.Caption, 3, Length(DBGrid1.Columns[LastColumn].Title.Caption) - 2);   qusp.Sql[icount] := 'order by ' + temp + ' asc';   DBGrid1.Columns[Column.Index].Title.Caption := '↑' + DBGrid1.Columns[Column.Index].Title.Caption;   lastcolumn := column.Index; end else begin   LastColumn := Column.Index;   title := DBGrid1.Columns[LastColumn].Title.Caption;   if Pos('↑', title) > 0 then   begin     qusp.Sql[icount] := 'order by ' + temp + ' desc';     Delete(title, 1, 2);     DBGrid1.Columns[LastColumn].Title.Caption := '↓' + title;   end   else if Pos('↓', title) > 0 then   begin     qusp.Sql[icount] := 'order by ' + temp + ' asc';     Delete(title, 1, 2);     DBGrid1.Columns[LastColumn].Title.Caption := '↑' + title;   end   else   begin     qusp.Sql[icount] := 'order by ' + temp + ' asc';     DBGrid1.Columns[LastColumn].Title.Caption := '↑' + title;   end; end; qusp.Open;end; 

热点排行