Hello
You can't add any control in the title cell but you can draw custom images and process mouse click
so it would looks like control is in the title cell.
Here is an example of code and demo.
Code:
procedure TForm1.DBGridEh1CellMouseClick(Grid: TCustomGridEh; Cell: TGridCoord;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer;
var Processed: Boolean);
begin
if (Cell.X = 1) and (Cell.Y = 0) and (Shift = []) then
begin
if (CheckBoxState = cbChecked) then
CheckBoxState := cbUnchecked
else
CheckBoxState := cbChecked;
DBGridEh1.InvalidateTitle;
end;
end;
procedure TForm1.DBGridEh1DrawTitleCell(Grid: TCustomDBGridEh; ACanvas: TCanvas;
const ARect: TRect; Params: TDBGridDrawTitleCellParamsEh;
var Processed: Boolean);
var
ForeInsideRect: TRect;
CustomRect: TRect;
begin
if Params.Column.FieldName = 'Name' then
begin
Grid.DrawTitleCellBackground(ACanvas, ARect, Params);
ForeInsideRect := Params.ForeInsideRect;
CustomRect := Params.ForeInsideRect;
ForeInsideRect.Left := ForeInsideRect.Left + 20;
CustomRect.Right := ForeInsideRect.Left;
Params.ForeInsideRect := ForeInsideRect;
Grid.DrawTitleCellForeground(ACanvas, ARect, Params);
DrawCheckBoxEh(ACanvas.Handle, CustomRect, CheckBoxState, True, True, False, False);
Processed := True;
end;
end;