我想在cxgird中实现复制当前单元格的功能,但是又要保持tableview的optionData的Editing为false,因为这项一设置为true,sgResultDblClick事件就不响应了.请告知如何实现.谢谢~

解决方案 »

  1.   

    自己截获CTRL+C/V的消息,通过代码给要paste的单元格赋值,不行吗?
      

  2.   

    sgResultDblClick事件里面写了什么?在添加的过程中需要去触发它么?
    如果不用,那么你在做复制的时候先把Editing改为True,添加了数据后改回来罗
      

  3.   

    cxGridCustomTableView
    cxGrid001       修改5492行 
    添加如下语句:
      ord('c'), ord('C'):
        begin
          if ssCtrl in Shift then
            Clipboard.AsText:=GetDisplayText(Controller.GetFocusedItemIndex);
        end;
      使表格在只读模式下可以复制选定单元格的数据.
      

  4.   

    cxgird的sgResultTableView1CustomDrawCell事件,和sgResultTableView1CellClick事件,这两个事件都只能取到当前选择的是哪一行,而不能取到当前是哪一列.我想做出单击右键菜单'复制'的功能,可是取不到当前cell的值,因为取不到当前是哪一列.如果把sgResultTableView的optionData的Editing设置为true,倒是可以实现右键复制,可是一来数据就可能会被用户改变,二来sgResultDblClick事件就不响应了.
      

  5.   

    数据复制到剪切板,那直接操作剪切板不就行了?
    var
      cpb:TClipBoard;
    然后调用cpb的方法
      

  6.   

    取不到当前cell的值,因为取不到当前是哪一列,只能取到当前是那一行
      

  7.   

    在 Form 的 OnKeyDown
    var
      SCT : TWinControl;
      Controller:TcxCustomGridTableController;
    begin
      //先看当前的焦点是什么
      SCT := ActiveControl;
      while SCT <> nil do
      begin
        if(SCT.Name = '') then
        begin
          SCT := SCT.Parent;
        end else
        begin
          Break;
        end;
      end;  if(ssCtrl in Shift) then
      begin
        if( Key = Ord('C')) then
        begin
          //Ctrl + C
          if( SCT is TcxGrid) then
          begin
            if ( TcxGrid(SCT).FocusedView.Controller is TcxCustomGridTableController ) then
            begin
              try
                Controller := TcxCustomGridTableController(TcxGrid(SCT).FocusedView.Controller);
                AStr := Controller.FocusedRecord.DisplayTexts[Controller.FocusedItem.Index];
                Clipboard.AsText := AStr;
              except
              end;
            end;
          end;
        end;
      end;
      

  8.   

    谢谢 xzq() ,解决问题!用ctrl+C来复制也好.