
The Header control provides a bar with a series of column headers, which can be placed above other controls on a form. The user can resize the sections of the header but the programmer must add code to make other controls follow the changes. A header might be placed, for example, over a number of edit boxes or list boxes so the user could be given more flexibility over the width of the controls.
The Sections property in the Object Inspector opens an editor for creating sections in the header.

Each section has its own properties:

With an Image List added to the example, the ImageIndex for this section has been set to the index in the list. Also in the example below, the HotTrack property has been set to True so that the headings in the header change colour as the mouse passes over them. At run-time the Width property is tracked in code and used to keep the controls underneath the header in line with the header sections.
Here is the form in design:

The controls here include two list boxes and a rich edit, but a range of other controls might also have been used.
At run-time the header's section borders can be dragged to cover up part of the two list boxes:

Here they have been dragged to reveal the text in the list boxes.

The code for changing the borders of the controls is as follows:
procedure TForm1.HeaderControl1SectionResize(HeaderControl: THeaderControl;
Section: THeaderSection);
begin
if section.Index=0 then
begin
listbox1.Width:=headercontrol1.Sections.Items[0].Width;
listbox2.Left:=listbox1.Width + 3;
richedit1.Left:=headercontrol1.Sections.Items[0].Width + 3
+ headercontrol1.Sections.Items[1].Width
end
else
if section.Index=1 then
begin
listbox2.Width:= headercontrol1.sections.items[1].width - 3;
richedit1.left:=headercontrol1.sections.items[0].width +
headercontrol1.sections.items[1].width ;
end;
end;
This code was created by choosing the OnSectionResize event from the Property Inspector and using the Section parameter (of type THeaderSection) to identify the section border being changed. It is then a matter of working out where the borders of the controls below the header must go in order to match the change in the header sections. A spacer of 3 pixels has been used to place the border lines of the header sections between the controls.