Components for Delphi and C++ Builder.

Go to Russian forum
Go to EhLib.com
It is currently 25 Apr 2024, 05:23

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Title Checkbox
PostPosted: 24 Feb 2020, 20:55 
Offline

Joined: 24 Aug 2018, 13:15
Posts: 46
Location: Brazil
Is it possible to add this functionality to DBGridEh components?


The checkbox on the title of the cell?
Image


Top
 Profile  
 
 Post subject: Re: Title Checkbox
PostPosted: 24 Feb 2020, 22:13 
Offline

Joined: 08 May 2014, 18:06
Posts: 663
Hello

Yes, you can.

Use DBGridEh.OnDrawTitleCell to draw title cell
DBGridEh.OnCellMouseClick to react title click
(dgColumnResize in OptionsEh should be disabled)

Code:
procedure TForm1.DBGridEh1CellMouseClick(Grid: TCustomGridEh; Cell: TGridCoord;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer;
  var Processed: Boolean);
var
  Column: TColumnEh;
begin
   if (Cell.X >= 1) and (Cell.X < DBGridEh1.Columns.Count - 2) then
   begin
     Column := DBGridEh1.Columns[Cell.X - 1];
   end
   else
   begin
     Exit;
   end;

  if (Cell.Y = 0) and (Column.FieldName = 'DateTimeField1') then
  begin
    DBGridEh1.SelectedRows.SelectAll;
  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 = 'DateTimeField1') 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, cbChecked, True, True, False, False);

    Processed := True;
  end;
end;

_________________
Best regards
EhLib Support Team


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group