打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
cxgrid如何多选输出记录

//mouse多选事件
 procedure Tpick_picture_win.cxGrid1DBTableView1DragOver(Sender: TObject; Source: TObject; X: Integer; Y: Integer; State: TDragState; var Accept: Boolean);

procedure SwapInt(var A, B: integer);
  var
    tmp: Integer;
  begin
    tmp := a;
    a := b;
    b := tmp;
  end;
var
  AHitTest: TcxCustomGridHitTest;//TcxCustomGridHitTest;
  i, IndexStart, IndexEnd: integer;
begin
  if cxGrid1DBTableView1.DragMode <> dmAutomatic then
    Exit;
  if cxGrid1DBTableView1.OptionsSelection.MultiSelect = False then
    Exit;
  cxGrid1DBTableView1.BeginUpdate;
 AHitTest :=  cxGrid1DBTableView1.GetHitTest(X, Y);
 // AHitTest := (Sender as TcxGridSite).GridView.ViewInfo.GetHitTest(X, Y);
  if AHitTest is TcxGridRecordHitTest then
  begin
    IndexStart := cxGrid1DBTableView1.Controller.FocusedRecord.Index;
    IndexEnd := TcxGridRecordHitTest(AHitTest).GridRecord.Index;
    cxGrid1DBTableView1.Controller.ClearSelection;
    if IndexEnd < IndexStart then
      SwapInt(IndexStart, IndexEnd);
    for i := IndexStart to IndexEnd do
      cxGrid1DBTableView1.ViewData.Records[i].Selected := True;
  end;
  cxGrid1DBTableView1.EndUpdate; 
  
end;
 

//调用
with   cxGrid1DBTableView1.DataController do
      
        begin
             selcount:=Controller.SelectedRecordCount; 


for k:=0 to selcount-1 do
          begin
               j:=GetSelectedRowIndex(k);
               Controller.FocusedRecordIndex:=j; 
          if flist.IndexOf( dataset.fieldbyname('cpbh').asstring)>-1 then
          begin
              atable.first;
              while not atable.eof do
              begin
                if atable.fieldbyname(sametext).asstring=dataset.fieldbyname('cpbh').asstring then
                begin
                atable.Delete;
                break;
                  
                end
                else
                atable.next;
                end;
                
            end;    
          atable.Append;  
          for i:=0 to sourcetitlelist.count-1 do
          begin     
            if destlist.strings[i]='无' then continue;
             if pos('图片',sourcetitlelist.Strings[i])=0 then 
            atable.fieldbyname( destlist.strings[i]).asstring := dataset.fieldbyname(sourcezdlist.strings[i]).asstring
            else
            begin
       
            if   dataset.fieldbyname(sourcezdlist.strings[i]).asstring<>'' then
            begin   
          
             mys:=Tmemorystream.Create;
           TBlobField(dataset.fieldbyname(sourcezdlist.strings[i])).SaveToStream(mys);   
            mys.Position:=0;
              TBlobField(atable.fieldbyname(destlist.strings[i])).LoadFromStream(mys); 
              //showmessage('1');
              mys.Free;
            end; 
              
            end;
          end;
          atable.post;
          //dataset.next;
          end; 
       end;  
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
xgrid 问题集
数据类型
delphi增删改查
Delphi 控件 cxGrid(DevExpress控件)的使用方法
Cxgrid获取选中行列,排序规则
在Delphi编程中利用Excel实现动态报表
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服