unit Unit_Q_20998677;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, Grids, DBGrids, Buttons, StdCtrls, ExtCtrls,
DBCtrls;
type
TForm1 = class(TForm)
qryNAMES: TQuery;
dsqNAMES: TDataSource;
dbgNAMES: TDBGrid;
spbSelectAll: TSpeedButton;
spbSelectCurrent: TSpeedButton;
spbUnSelectAll: TSpeedButton;
spbUnSelectCurrent: TSpeedButton;
DBNavigator1: TDBNavigator;
procedure FormCreate(Sender: TObject);
procedure spbSelectAllClick(Sender: TObject);
procedure spbSelectCurrentClick(Send
procedure spbUnSelectAllClick(Sender
procedure spbUnSelectCurrentClick(Se
private{ Private declarations }
SID: string;
public { Public declarations }
procedure SelectAllNames(Value: Boolean);
procedure GoToCell(Col,Row: Integer);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
qryNAMES.Active := True;
SID := dbgNAMES.DataSource.DataSe
end;
procedure TForm1.SelectAllNames(Valu
var
C: Integer;
I: Integer;
begin
with dbgNAMES.DataSource.DataSe
try
dbgNAMES.Visible := False;
begin
DisableControls;
First;
while not EOF do
begin
dbgNAMES.SelectedRows.Curr
Next;
end;
end;
finally
EnableControls;
Val(SID, I, C);
if (I>0) and (C=0) then
Locate('ID', SID, []);
dbgNAMES.Visible := True;
end;
end;
procedure TForm1.spbSelectAllClick(S
begin
SID := dbgNAMES.DataSource.DataSe
SelectAllNames(True);
end;
procedure TForm1.spbUnSelectAllClick
begin
SID := dbgNAMES.DataSource.DataSe
SelectAllNames(False);
end;
procedure TForm1.GoToCell(Col,Row: Integer);
var
S: string;
begin
with dbgNAMES.DataSource.DataSe
try
GotoBookmark(Pointer(dbgNA
S := '['+IntToStr(Col)+','+IntT
except
end;
end;
procedure TForm1.spbSelectCurrentCli
begin
with dbgNAMES.DataSource.DataSe
dbgNAMES.SelectedRows.Curr
end;
procedure TForm1.spbUnSelectCurrentC
begin
with dbgNAMES.DataSource.DataSe
dbgNAMES.SelectedRows.Curr
end;
end.
//......................
object Form1: TForm1
Left = 212
Top = 114
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsSingle
Caption = 'Form1'
ClientHeight = 414
ClientWidth = 408
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object spbSelectAll: TSpeedButton
Left = 256
Top = 16
Width = 96
Height = 22
Caption = 'Select All'
OnClick = spbSelectAllClick
end
object spbSelectCurrent: TSpeedButton
Left = 256
Top = 128
Width = 96
Height = 22
Caption = 'Select Current'
OnClick = spbSelectCurrentClick
end
object spbUnSelectAll: TSpeedButton
Left = 256
Top = 48
Width = 96
Height = 22
Caption = 'UnSelect All'
OnClick = spbUnSelectAllClick
end
object spbUnSelectCurrent: TSpeedButton
Left = 256
Top = 160
Width = 96
Height = 22
Caption = 'UnSelect Current'
OnClick = spbUnSelectCurrentClick
end
object dbgNAMES: TDBGrid
Left = 22
Top = 48
Width = 224
Height = 352
DataSource = dsqNAMES
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 DBNavigator1: TDBNavigator
Left = 36
Top = 16
Width = 160
Height = 22
DataSource = dsqNAMES
VisibleButtons = [nbFirst, nbPrior, nbNext, nbLast, nbRefresh]
TabOrder = 1
end
object qryNAMES: TQuery
SQL.Strings = (
'SELECT * FROM SINGERS')
Left = 26
Top = 84
end
object dsqNAMES: TDataSource
DataSet = qryNAMES
Left = 54
Top = 84
end
end
Main Topics
Browse All Topics





by: mokulePosted on 2004-05-22 at 12:48:38ID: 11134671
procedure TForm1.Button1Click(Sender : TObject); .DisableCo ntrols;
.First; .Next;
.Locate('D ok_id',2,[ ]);
.EnableCon trols;
var
i: integer;
begin
// to allow row select
DBGrid1.Options := DBGrid1.Options - [dgEditing]+ [dgRowSelect];
DBGrid1.DataSource.DataSet
// if You want to select 6th row for example
DBGrid1.DataSource.DataSet
for i := 0 to 4 do
DBGrid1.DataSource.DataSet
// if You want select raw fulfilling some criteria
DBGrid1.DataSource.DataSet
DBGrid1.DataSource.DataSet
ActiveControl := DBGrid1;
end;