Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[503] [정보] 아래 DBGrid 멀티셀렉션시 참고..
sickchic [ ] 2930 읽음    1997-12-31 22:15
   
    TDBGrid에서 여러개의 래코드를 선택한후..
   
    한번에 처리를 하려고 밑에 제가 올렸었던 소스를 이용해봤습니다..
   
   
    TDBGrid의    Options    프로퍼티의   dgMultiSelect   값만   True로
    설정해주고..
    아래의 소스를 그대로 사용하시면 됩니다..
   
   
    근데  우스운 것은.. DBGrid의 SelectedRows 프로퍼티가 분명히 존재함
    에도 델파이 2.0의 도움말에서는 아무리 찾아봐도 찾을 수가 없다는 것
    이죠.. (델파이 2.0의 도움말이 업그레이드가 되었네 하는 이야기를 들
    은 것도 같은데..)
   
    SelectedRows 프로퍼티는 TBookmarkList 형인데..
   
    TBookmarkList 형 역시.. 도움말에선 찾을 수가 없네요..
    (근데.. 3.0 도움말엔 나오네.. 흘흘..)
   
   
    아래  TBookmarkList  형의 정의를 VCL 소스에서 찾아다 붙여 놓았습니
    다.. 코딩하시는데 도움이 될 거여요..
   
    기람..
                                미친병아리 서비였네용.. 삐약~ !!
   
   
   
   
    procedure TForm1.SelectClick(Sender: TObject);
    var
      x: word;
      TempBookmark: TBookMark;
    begin
      DBGrid1.Datasource.Dataset.DisableControls;
      with DBgrid1.SelectedRows do
      if Count > 0 then
      begin
        TempBookmark:= DBGrid1.Datasource.Dataset.GetBookmark;
        for x:= 0 to Count - 1 do
        begin
          if IndexOf(Items[x]) > -1 then
          begin
            DBGrid1.Datasource.Dataset.Bookmark:= Items[x];
            showmessage(DBGrid1.Datasource.Dataset.Fields[1].AsString);
          end;
        end;
      end;
      DBGrid1.Datasource.Dataset.GotoBookmark(TempBookmark);
      DBGrid1.Datasource.Dataset.FreeBookmark(TempBookmark);
      DBGrid1.Datasource.Dataset.EnableControls;
    end;
   
   
   
   
      TBookmarkList = class
      private
        FList: TStringList;
        FGrid: TCustomDBGrid;
        FCache: TBookmarkStr;
        FCacheIndex: Integer;
        FCacheFind: Boolean;
        FLinkActive: Boolean;
        function GetCount: Integer;
        function GetCurrentRowSelected: Boolean;
        function GetItem(Index: Integer): TBookmarkStr;
        function Insert(const Item: TBookmarkStr): Integer;
        procedure SetCurrentRowSelected(Value: Boolean);
        procedure StringsChanged(Sender: TObject);
      protected
        function CurrentRow: TBookmarkStr;  // shortcut to grid.datasource...
        function Compare(const Item1, Item2: TBookmarkStr): Integer;
        procedure LinkActive(Value: Boolean);
      public
        constructor Create(AGrid: TCustomDBGrid);
        destructor Destroy; override;
        procedure Clear;           // free all bookmarks
        procedure Delete;          // delete all selected rows from dataset
        function  Find(const Item: TBookmarkStr; var Index: Integer): Boolean;
        function  IndexOf(const Item: TBookmarkStr): Integer;
        function  Refresh: Boolean;// drop orphaned bookmarks;
                                   // True = orphans found
        property Count: Integer read GetCount;
        property CurrentRowSelected: Boolean read GetCurrentRowSelected
          write SetCurrentRowSelected;
        property Items[Index: Integer]: TBookmarkStr read GetItem; default;
      end;
   
   
   
   


+ -

관련 글 리스트
503 [정보] 아래 DBGrid 멀티셀렉션시 참고.. sickchic 2930 1997/12/31
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.