Código
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.
Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009