cxgrid的多選記錄 修改記錄問題

來源:互聯網
上載者:User

 

cxgrid的多選記錄 修改記錄問題 vga 發表於2011-06-18 08:08 瀏覽(60)
評論(1) 分類:我的日記
     舉報

cxgrid 雙擊 擷取所點擊行的內容

建立view的 optionsselection->cellselect 設定為false ,才能觸發雙擊事件

案例:

procedure TForm_Child_Archive.cxGrid1DBTableView1CellDblClick(
  Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo;
  AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin3

      ////取得所雙擊列的列表頭名稱  ACellViewInfo.Item.Index 為所雙擊列
      //ShowMessage(cxGrid1DBTableView1.Columns[ACellViewInfo.Item.Index].Caption);

       with  cxGrid1DBTableView1.DataController do
       begin
           //取某行某列的值 ,取第5列,參數4
          ShowMessage(Values[FocusedRecordIndex,4]);
      end;

end;

其他:

如果不需要對儲存格進行選擇可:設定CXGrid的TableView對象的OptionsSelection->CellSelect 為False;
如果需要對儲存格進行選擇可:設定CXGrid的TableView對象的OptionsData中的全部屬性 為False;  

cxgrid的多選記錄 修改記錄問題

cxgrid多選  , 有可能是連續的,有可能是隔了其他記錄的   
cxgrid 把 cxGrid1DBTableView1——》 optionselection——》multiselect設為true就可以了  

GridView.DataController.DataModeController.GridMode=True;

修改選中的記錄中一個欄位  :

sample1:

procedure   TForm1.btnSelectValueClick(Sender:   TObject);  
  var  
      I,   J:Integer;  
  begin  
      for   I:=0   to   tvcxgd1DBTableView1.DataController.GetSelectedCount-1   do   begin  

          J:=tvcxgd1DBTableView1.DataController.GetSelectedRowIndex(I);  
          ShowMessage(VarToStr(tvcxgd1DBTableView1.DataController.GetValue(J,0)));  

      end;  
  end; sample2:

Var  
      i:integer;      
  begin  
      For   i:=0   To   cxGrid1DBTableView1.Controller.SelectedROwCount-1   Do  
      begin  
          cxGrid1dbtableview1.Controller.FocusedRow:=cxGrid1dbtableview1.Controller.SelectedRows[i];  

          Adoquery1.Edit;  
          Adoquery1.FieldByName('DeptName').AsString:=Edit1.Text  
          Adoquery1.Post;  
      end;  
  end;

摘自:

摘自:

進行cxgrid多行記錄刪除

procedure TForm1.Button1Click(Sender: TObject);

var

i : integer;

sID : string;

adotmp : TADOQuery;

begin

//Values[0] 為欄位a

//Values[1] 為識別欄位

//cxgrdItemList 為cxGrid

sID := '0';

for i := 0 to cxgrdItemList.DataController.Controller.SelectedRecordCount - 1 do

begin

    if cxgrdItemList.DataController.Controller.SelectedRecords[i].Values[0] = True then

      continue;

    sID := sID + ', ' + cxgrdItemList.DataController.Controller.SelectedRecords[i].Values[1];

end;

adotmp := TADOQuery.Create(nil);

with adotmp do

try

    {自己寫

    Connection := ;

    }

    sql.Text := 'delete from yTbName where ID in (' + sID + ')';

    ExecSQL;

finally

    free;

    //重新整理一下cxgrid的dataset;

end;

end

  http://wo.115.com/?ct=detail&id=32100&bid=1408771

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.