9

I've been producing videos on using delphi components for my website LearnDelphi.tv. I'm looking to cover THeaderControl but can't find any use for it - is this component now not required - surpassed by other components such as TListView (with the report viewstyle) or is there some way of using it that I've overlooked?

Edit: I recorded a segment on THeaderControl for one of my commercial videos, but I have decided to release this small section (20 minutes out of 6 hours) for free. Watch it on YouTube. Thanks to everyone who has contributed.

Alister
  • 6,527
  • 4
  • 46
  • 70
  • 1
    It used to be good for a header on a normal list with tabs, but it is indeed less used now. Not sure this is a good place to ask such a question though. (I didn't downvote!) – mj2008 Jul 16 '12 at 11:31
  • 1
    @TLama I've looked at the help, and done quite a reasonable Google search. An example keeps popping up for headers on a TListBox, which is quite fiddly to implement - and using a TListView is much easier - I was wondering if anyone was using it to do something useful. – Alister Jul 16 '12 at 11:40
  • 1
    I don't understand this question. You appear to be looking for a reason to use the header control. Do you have a specific problem with the list view control? – David Heffernan Jul 16 '12 at 11:45
  • 2
    @DavidHeffernan, he's making videos about Delphi, and is wondering if THeaderControl is worth his time. That's all. – Chris Thornton Jul 16 '12 at 12:14
  • 4
    @Chris Aha, now I understand. I don't think THeaderControl is very mainstream. – David Heffernan Jul 16 '12 at 12:18
  • 2
    I just had that scenario 2 days ago: replacing TListBox+THeaderControl with TListView. Lot of old resize-code in the waste bin ;-) – Jan Doggen Jul 16 '12 at 13:38

1 Answers1

11

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;

enter image description here

NGLN
  • 43,011
  • 8
  • 105
  • 200