zoukankan      html  css  js  c++  java
  • 有关Ehlib中DbGridEh控件的多行选择

    在dbgrideh中允许选择多行,如何知道哪些行被选中? 
    是个BOOKMARK类型的属性。
    SelectedRows: TBookmarkList
    procedure TForm1.Button1Click(Sender: TObject);
    var
     i, j: Integer;
     s: string;
    begin
     if DBGrid1.SelectedRows.Count>0 then
       with DBGrid1.DataSource.DataSet do
         for i:=0 to DBGrid1.SelectedRows.Count-1 do
         begin
           GotoBookmark(pointer(DBGrid1.SelectedRows.Items[i]));
           for j := 0 to FieldCount-1 do
           begin
             if (j>0) then s:=s+‘, ‘;
             s:=s+Fields[j].AsString;
           end;
           Listbox1.Items.Add(s);
           s:= ‘‘;
         end;
    end;   
     
    dbgrideh 上选择多行之后,要求把所选择的记录全部添加入SQL数据库的一个固定表中。 
    dbgrideh.selectedrows记载了所有被选择行的bookmark;利用SelectedRows和GotoBookmark完成。代码如下:

    procedure TForm1.Button1Click(Sender: TObject);
    var
     i, j: Integer;
     s: string;
    begin
     if DBGrid1.SelectedRows.Count>0 then
       with DBGrid1.DataSource.DataSet do
         for i:=0 to DBGrid1.SelectedRows.Count-1 do
         begin
           GotoBookmark(pointer(DBGrid1.SelectedRows.Items[i]));
           for j := 0 to FieldCount-1 do
           begin

             if (j>0) then s:=s+‘, ‘;
             s:=s+Fields[j].AsString;
           end;
           Listbox1.Items.Add(s);
           s:= ‘‘;
         end;
    end; 
  • 相关阅读:
    差分约束
    POJ 2449 Remmarguts' Date[k短路]
    K短路
    hdu4034 Graph(floyd)
    hdu2089不要62(数位dp)
    POJ3468 A Simple Problem with Integers ( 线段树)
    POJ3255:Roadblocks(次短路 SPFA+A星)
    usaco2.1Ordered Fractions( 枚举, 数学)
    hdu1565方格取数(1) (状态压缩dp)
    poj3259 Wormholes(spfa)
  • 原文地址:https://www.cnblogs.com/chenbg2001/p/1922643.html
Copyright © 2011-2022 走看看