Buscar

Como congelar a primeira coluna do dbgrid

Código

Type
THack = class(TDBGrid);

// evento onclick do botão para congelar coluna

procedure TForm1.Button1Click(Sender: TObject);
begin
THack(DBGrid1).Columns[0].ReadOnly := True;
THack(DBGrid1).FixedCols := 2;
end;

// evento onColEnter do DBGrid

procedure TForm1.DBGrid1ColEnter(Sender: TObject);
begin
if (THack(DBGrid1).SelectedIndex = 0) then
begin
THack(DBGrid1).LeftCol := 2;
THack(DBGrid1).SelectedIndex := 1;
end;
end;

// evento onKeyDown do componente DBGrid

procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Key = VK_Left) and (THack(DBGrid1).SelectedIndex = 1) then
Key := VK_Clear;
end;
end.

 

Publicidade

Vote na dica




Quantidade de votos: 0 votos
Aceitação: 0%


Detalhes da dica

Categoria: Componentes
Adicionada dia: 20/08/07
Por: Jaber S. C. Lima
Visualizada: 35271 vezes

Planeta Delphi - Tudo sobre programação Delphi Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009