Batman
شنبه 16 شهریور 1387, 09:49 صبح
با سلام دوستان چجوری میشه تمام رکوردهای dbgrid رو انتخاب کرد
و بعد چجوری میشه فهمید که تمام رکوردها انتخاب شده اند یا خیر؟
ممنونم
Hsimple11
شنبه 16 شهریور 1387, 17:22 عصر
procedure DBGridSelectAll(AGrid: TDBGrid) ;
begin
AGrid.SelectedRows.Clear;
with AGrid.DataSource.DataSet do
begin
DisableControls;
First;
try
while not EOF do
begin
AGrid.SelectedRows.CurrentRowSelected := True;
Next;
end;
finally
EnableControls;
end;
end;
end;
یا با فشردن کلید Shift. یک کامپوننت مشتق از DbGrid :
unit SelDBGrid;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids;
type
TSelDBGrid = class(tdbgrid)
private
{ Private declarations }
protected
procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override;
public
{ Public declarations }
published
{ Published declarations }
end;
procedure Register;
implementation
procedure TSelDBGrid.WMLButtonDown(var Message: TWMLButtonDown);
begin
if message.Keys and MK_SHIFT <> 0 then
begin
message.Keys := message.Keys and MK_SHIFT; //Discard shift
if message.Keys and MK_CONTROL = 0 then
message.Keys := message.Keys or MK_CONTROL; //add Control
end;
inherited;
end;
procedure TSelDBGrid.DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);
begin
AState := AState - [gdSelected]; //Remove SelectedState preventive
inherited DrawCell(ACol,ARow,ARect,AState);
end;
procedure Register;
begin
RegisterComponents('Samples', [TSelDBGrid]);
end;
end.
Batman
شنبه 16 شهریور 1387, 20:23 عصر
ممنونم اما کدی که شما گذاشتید اگر تعداد رکوردها بالا بره سرعت پایین میاد
بهر حال ممنونم
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.