listview中有10条记录,当我选择到其中的一条的时候,按移动按钮,先判断不是第一条记录,如果不是的话前上一条记录和该条记录位置交换。
请大侠指点一下
或者你有listview相关的也可以和我说说,我的书上对这一方面介绍的很少,几乎是没有介绍

解决方案 »

  1.   

    我有个,给你吧
    procedure TFstudent.bsSkinSpeedButton1Click(Sender: TObject);
    var
    str,str1:string;
    begin
    if dm.ADOTstudent.RecordCount>1 then
       begin
       str:=dm.ADOTstudent.fieldbyname('姓名').AsString;
       dm.ADOTstudent.Prior;
       if not dm.ADOTstudent.Bof then
       begin
       str1:=dm.ADOTstudent.fieldbyname('姓名').AsString;
       dm.ADOTstudent.Edit;
       dm.ADOTstudent.FieldByName('姓名').AsString:=str;
       dm.ADOTstudent.Post;
       dm.ADOTstudent.Next;
       dm.ADOTstudent.Edit;
       dm.ADOTstudent.FieldByName('姓名').AsString:=str1;
       dm.ADOTstudent.Post;
       dm.ADOTstudent.Prior;
       end;
       end;
    end;procedure TFstudent.bsSkinSpeedButton2Click(Sender: TObject);
    var
    str,str1:string;
    begin
    if dm.ADOTstudent.RecordCount>1 then
       begin
       str:=dm.ADOTstudent.fieldbyname('姓名').AsString;
       dm.ADOTstudent.Next;
       if not dm.ADOTstudent.Eof then
       begin
       str1:=dm.ADOTstudent.fieldbyname('姓名').AsString;
       dm.ADOTstudent.Edit;
       dm.ADOTstudent.FieldByName('姓名').AsString:=str;
       dm.ADOTstudent.Post;
       dm.ADOTstudent.Prior;
       dm.ADOTstudent.Edit;
       dm.ADOTstudent.FieldByName('姓名').AsString:=str1;
       dm.ADOTstudent.Post;
       dm.ADOTstudent.Next;
       end;
       end;
    end;