Chapter 13 - Project mltgrid |
Project Structure
| mltgrid.dpr |
program mltgrid;
uses
Forms,
mltdbgrd in 'mltdbgrd.pas' ;
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
| mltdbgrd.pas |
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
public
end;
var
Form1: TForm1;
implementation
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
BookmarkList: TBookmarkList;
Bookmark: TBookmarkStr;
begin
Bookmark := Table1.Bookmark;
try
ListBox1.Items.Clear;
BookmarkList := DbGrid1.SelectedRows;
for I := 0 to BookmarkList.Count - 1 do
begin
Table1.Bookmark := BookmarkList[I];
ListBox1.Items.Add (Table1.FieldByName (
'Name').AsString);
end;
finally
Table1.Bookmark := Bookmark;
end;
end;
end.
| mltdbgrd.dfm |
object Form1: TForm1
Left = 98
Top = 177
Width = 563
Height = 318
Caption = 'Multiple Selection Grid'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
PixelsPerInch = 96
TextHeight = 13
object Splitter1: TSplitter
Left = 385
Top = 0
Width = 0
Height = 291
Cursor = crHSplit
end
object DBGrid1: TDBGrid
Left = 0
Top = 0
Width = 385
Height = 291
Align = alLeft
DataSource = DataSource1
Options = [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgConfirmDelete, dgCancelOnExit, dgMultiSelect]
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
end
object Panel1: TPanel
Left = 385
Top = 0
Width = 170
Height = 291
Align = alClient
TabOrder = 1
object ListBox1: TListBox
Left = 9
Top = 40
Width = 150
Height = 241
ItemHeight = 13
TabOrder = 0
end
object Button1: TButton
Left = 11
Top = 8
Width = 150
Height = 25
Caption = 'Get Selected'
TabOrder = 1
OnClick = Button1Click
end
end
object DataSource1: TDataSource
DataSet = Table1
Left = 32
Top = 24
end
object Table1: TTable
Active = True
DatabaseName = 'DBDEMOS'
TableName = 'COUNTRY.DB'
Left = 88
Top = 24
end
end
|
|