HeaderSection (C++)
Description
Add a THeaderControl to the form and call HeaderControl1DrawSection for the OnDrawSection event.
Code
void __fastcall TForm1::HeaderControl1DrawSection(THeaderControl *HeaderControl,
THeaderSection *Section, const TRect &Rect, bool Pressed)
{
if (Pressed)
HeaderControl->Canvas->Font->Color = clRed;
else
HeaderControl->Canvas->Font->Color = clBlue;
HeaderControl->Canvas->TextOut(Rect.Left + HeaderControl->Canvas->Font->Size, Rect.Top + 2, "Custom " + IntToStr(Section->Index));
}
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
THeaderSection *Section;
for (int i = 0; i <= 4; i++)
{
Section = HeaderControl1->Sections->Add();
Section->Text = "Section " + IntToStr(i);
Section->MinWidth =
(Section->Text).Length() *
HeaderControl1->Font->Size;
// Owner draw every other section
if (i % 2 == 0)
Section->Style = hsOwnerDraw;
else
Section->Style = hsText;
}
}
Uses
- Vcl.ComCtrls.THeaderControl.OnDrawSection ( fr | de | ja )
- Vcl.ComCtrls.THeaderControl.Sections ( fr | de | ja )
- Vcl.ComCtrls.TCustomHeaderControl.Canvas ( fr | de | ja )
- Vcl.ComCtrls.THeaderSection.Style ( fr | de | ja )
- Vcl.ComCtrls.THeaderSection.Text ( fr | de | ja )
- Vcl.Graphics.TCanvas.TextOut ( fr | de | ja )
- Vcl.Graphics.TFont.Color ( fr | de | ja )