In general: THeaderControl
can be used as header for tabular data. Of course, often a list view is used for that. But for an exotic layout of different components in each column that would not be easy to create by using a list view or similar, or for even complete different layouts for each column, the header control could be usefull. It simply offers more flexibility there where it is needed. Compare it with TPageControl
offering more flexibility than TTabControl
.
And about a specific niche case: for example, I use the header control as part of a planning grid component. The header control gets his captions via a data source, and the header sections are in sync with the columns and the scroll bar. Indeed, this requires some code, but not more than when implementing the different events designtime:
TPlanGridHeader = class(TCustomHeaderControl)
private
FSectionWidth: Integer;
procedure SetSectionWidth(Value: Integer);
procedure WMMouseMove(var Message: TWMMouseMove); message WM_MOUSEMOVE;
protected
function CreateSection: THeaderSection; override;
procedure SectionResize(Section: THeaderSection); override;
procedure SectionTrack(Section: THeaderSection; Width: Integer;
State: TSectionTrackState); override;
property SectionWidth: Integer read FSectionWidth write SetSectionWidth;
public
procedure AddSection(const AText, AHint: String);
constructor Create(AOwner: TComponent); override;
end;
