線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:894
推到 Plurk!
推到 Facebook!

[Delphi問題]麻煩請幫幫忙~DBGrid中想知道選出來的值有哪些

尚未結案
tinny
一般會員


發表:4
回覆:2
積分:1
註冊:2005-10-13

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-10-13 14:02:40 IP:218.171.xxx.xxx 未訂閱
我在DBgrid中用多重選擇的方式將值選出來再塞入至另一個的dbgrid1中 要如何知道dbgrid中篩選出來值的某一個欄位(只需要知道學號這個欄位值)    < >< >
Fishman
尊榮會員


發表:120
回覆:1949
積分:2163
註冊:2006-10-28

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-10-13 14:52:13 IP:210.65.xxx.xxx 未訂閱
Hi tinny,
procedure TForm1.Button3Click(Sender: TObject);
var
  i: Integer;
  SavePlace: TBookmark;
begin
  Memo1.Lines.Clear;
  if DBGrid2.SelectedRows.Count > 0 then
    begin
      SavePlace := DBGrid2.DataSource.DataSet.GetBookmark;
      try
        for i:=0 to DBGrid2.SelectedRows.Count-1 do
          begin
            DBGrid2.DataSource.DataSet.GotoBookmark(pointer(DBGrid2.SelectedRows.Items[i]));
            Memo1.Lines.Add(DBGrid2.DataSource.DataSet.FieldByName('id').AsString); // all the rows been selected
          end;
      finally
        DBGrid2.DataSource.DataSet.GotoBookmark(SavePlace);
        DBGrid2.DataSource.DataSet.FreeBookmark(SavePlace);
      end;
    end;
end;
For more detail information and sample codes, you can search the help on delphi with key word SelectedRows, GetBookmark, GotoBookmark, FreeBookmark... ---------------------------------- 小弟才疏學淺,若有謬誤尚請不吝指教 ----------------------------------
------
Fishman
系統時間:2024-05-11 17:05:54
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!