Skip to main content

TcxCustomHeader.OnDrawSection Event

Occurs when it is necessary to draw/redraw a header section.

Declaration

property OnDrawSection: TcxDrawSectionEvent read; write;

Remarks

The OnDrawSection event occurs before a section of the TcxHeader control is redrawn. Handle the OnDrawSection event if you wish to override the section’s default painting.

Parameter Meaning
Sender The header control which fired the event
Section The header section to be painted
ARect A rectangle object defining the position and the size of the section’s drawing rectangle
Pressed True, if the section is being clicked, False – in other cases.

Example

This example implements custom painting of the cxHeader control by handling the OnDrawSection event. Note: the cxGraphics unit needs to be added to your uses clause.

procedure TForm1.cxHeader1DrawSection(HeaderControl: TcxCustomHeader;
  Section: TcxHeaderSection; const ARect: TRect; Pressed: Boolean);
begin
  if Pressed then
  begin
    HeaderControl.Canvas.Brush.Color := clBlue;
    HeaderControl.Canvas.Font.Color := clYellow;
    HeaderControl.Canvas.Font.Style := [fsBold];
  end else
  begin
    HeaderControl.Canvas.Brush.Color := clNavy;
    HeaderControl.Canvas.Font.Color := clWhite;
    HeaderControl.Canvas.Font.Style := [];
  end;
  HeaderControl.Canvas.FillRect(ARect);
  HeaderControl.Canvas.DrawTexT(Section.Text, ARect, cxAlignHCenter or cxAlignVCenter);
end;

The following images show the result of executing this code:

Header control is in normal state First section of the header control is clicked
See Also