mltdbgrd.pas
资源名称:delphi.rar [点击查看]
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:1k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit mltdbgrd;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- DB, DBTables, Grids, DBGrids, StdCtrls, ExtCtrls;
- type
- TForm1 = class(TForm)
- DBGrid1: TDBGrid;
- DataSource1: TDataSource;
- Table1: TTable;
- Splitter1: TSplitter;
- Panel1: TPanel;
- ListBox1: TListBox;
- Button1: TButton;
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.DFM}
- procedure TForm1.Button1Click(Sender: TObject);
- var
- I: Integer;
- BookmarkList: TBookmarkList;
- Bookmark: TBookmarkStr;
- begin
- // store the current position
- Bookmark := Table1.Bookmark;
- try
- // empty the listbox
- ListBox1.Items.Clear;
- // get the selected rows of the grid
- BookmarkList := DbGrid1.SelectedRows;
- for I := 0 to BookmarkList.Count - 1 do
- begin
- // for each, move the table to that record
- Table1.Bookmark := BookmarkList[I];
- // add the name field to the listbox
- ListBox1.Items.Add (Table1.FieldByName (
- 'Name').AsString);
- end;
- finally
- // go back to the initial record
- Table1.Bookmark := Bookmark;
- end;
- end;
- end.