zoukankan      html  css  js  c++  java
  • 双击dbgrid排序的问题

    有关双击dbgrid排序的问题(想让用户双击dbgird控件的某一个字段时就升序,再双击就降序....?)【DFW:DouZheng】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;

  • 相关阅读:
    CodeForces 733B Parade
    LeetCode 150 Evaluate Reverse Polish Notation
    LeetCode 148 Sort List
    数据库的迁移
    LeetCode 147. Insertion Sort List
    构建一个可以统计 qps 的nginx服务的Dockerfile
    各城市区号
    tkinter中menu菜单控件(十二)
    tkinter中scale拖拉改变值控件(十一)
    tkinter中spinbox递增和递减控件(十)
  • 原文地址:https://www.cnblogs.com/martian6125/p/9631541.html
Copyright © 2011-2022 走看看