procedure TForm1.DBGridEh1KeyPress(Sender: TObject;
var Key: Char);
var
ADBGridEh: TDBGridEh;
MyGrid: TMyGrid;
begin
if Key = #13 then
begin
Key := #0;
ADBGridEh := TDBGridEh(Sender);
MyGrid := TMyGrid(DBGridEh1);
if MyGrid.Row < MyGrid.RowCount - 1 then
exit;
ADBGridEh.DataSource.DataSet.Append;
ADBGridEh.SelectedIndex := 0;
end;
end;
procedure TForm1.DBGridEh1DrawColumnCell(Sender: TObject;
const Rect: TRect;
DataCol: Integer;
Column: TColumnEh;
State: TGridDrawState);
var
ADBGridEh: TDBGridEh;
MyGrid: TMyGrid;
r: TRect;
begin
ADBGridEh := TDBGridEh(Sender);
MyGrid := TMyGrid(ADBGridEh);
if MyGrid.Row < MyGrid.RowCount - 1 then
exit;
PostMessage(Handle, wm_my_do0, 0, 0);
end;
procedure TForm1.my_do0(var Message: TMessage);
var
ADBGridEh: TDBGridEh;
MyGrid: TMyGrid;
r, Rect, Rect0: TRect;
i: integer;
begin
ADBGridEh := DBGridEh1;
MyGrid := TMyGrid(ADBGridEh);
if not (ADBGridEh.DataSource.DataSet.State in [dsEdit, dsInsert]) then
begin
exit;
end;
if MyGrid.Row < MyGrid.RowCount - 1 then
exit;
with MyGriddo
begin
Canvas.Pen.Color := clSilver;
for i := 0 to ColCount - 1do
begin
Rect := CellRect(i, rowcount - 1);
r := Rect;
dec(r.Left);
inc(r.Right);
r.Bottom := Rect.Bottom + (Rect.Bottom - Rect.top);
inc(r.Bottom);
r.Top := Rect.Bottom;
if i = 0 then
begin
Canvas.Rectangle(r);
Rect0 := CellRect(0, 0);
inc(Rect0.Right);
r := Rect0;
r.Top := Rect.Bottom + 1;
r.Bottom := r.top + (Rect0.Bottom - Rect0.Top);
Canvas.CopyRect(r, Canvas, Rect0);
end
else
begin
Canvas.Rectangle(r);
end;
end;
end;
end;
procedure TForm1.DBGridEh1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
var
ADBGridEh: TDBGridEh;
MyGrid: TMyGrid;
acol, arow: integer;
r: TRect;
begin
ADBGridEh := TDBGridEh(Sender);
MyGrid := TMyGrid(ADBGridEh);
r := MyGrid.CellRect(0, MyGrid.RowCount - 1);
if (y < r.Bottom) or (y > r.Bottom + MyGrid.DefaultRowHeight) then
exit;
ADBGridEh.DataSource.DataSet.Append;
end;