Fórum Selecionar linhas no dbgrid #292423
20/08/2005
0
Cruel
Curtir tópico
+ 0Posts
20/08/2005
Gigatel
Oi tudo bem ?..vou te passar uma coisa seja mais útil...más caso queira mesmo usar um botão fique a vontade...que tal usar uma Tecla CTRL + A...ou CTRL+D para desmarcar...de qualquer forma está aí..no evento OnKeyPress coloque..
if key in [1, 4, 22] then
begin
DBGrid1.DataSource.DataSet.First;
while not DBGrid1.DataSource.DataSet.Eof do
begin
{Ctrl+A}
if key = 1 then
DBGrid1.SelectedRows.CurrentRowSelected := true;
{Ctrl+D}
if key = 4 then
DBGrid1.SelectedRows.CurrentRowSelected := false;
{Ctrl+I}
if key = 22 then
DBGrid1.SelectedRows.CurrentRowSelected := not DBGrid1.SelectedRows.CurrentRowSelected;
DBGrid1.DataSource.DataSet.Next;
espero ter ajudado...
Gostei + 0
20/08/2005
Marco Salles
primeiramente vc precisa passar para true a propriedade
Options.dgMultiSelect
Depois é conveniente usar a Propriedade DisableControls e enableControls
So acrescentando veja a diferença ... Qaunto maior os dados na tabela maior sera a diferença
procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
var
BookMark:TBookMarkStr;
begin
if key in [1, 4, 22] then
begin
BookMark:=Table1.Bookmark;
Table1.disablecontrols;
DBGrid1.DataSource.DataSet.First;
while not DBGrid1.DataSource.DataSet.Eof do
begin
{Ctrl+A}
if key = 1 then
DBGrid1.SelectedRows.CurrentRowSelected := true;
{Ctrl+D}
if key = 4 then
DBGrid1.SelectedRows.CurrentRowSelected := false;
DBGrid1.DataSource.DataSet.Next;
end;
Table1.enablecontrols;
Table1.Bookmark:=BooKmark;
end;
end;Gostei + 0
20/08/2005
Cruel
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)