我一直在为我的网站LearnDelphi.tv制作使用delphi组件的视频。我想要覆盖THeaderControl,但找不到它的任何用途 - 现在不需要这个组件 - 超过其他组件,如TListView(使用报告视图样式),或者是否有一些使用它的方法我忽略了?
编辑: 我在THeaderControl上为我的一个商业视频录制了一个片段,但我决定免费发布这个小片段(6小时内20分钟)。在YouTube上观看。感谢所有贡献的人。
答案 0 :(得分:11)
通常:THeaderControl
可用作表格数据的标题。当然,通常会使用列表视图。但是对于每列中不同组件的异乎寻常的布局,通过使用列表视图或类似方法不容易创建,或者对于每列甚至完全不同的布局,标题控件可能是有用的。它只需在需要的地方提供更大的灵活性。将其与TPageControl
进行比较,提供比TTabControl
更多的灵活性。
关于特定的利基案例:例如,我使用标题控件作为计划网格组件的一部分。标题控件通过数据源获取标题,标题部分与列和滚动条同步。实际上,这需要一些代码,但不能超过实现不同事件设计时的时间:
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;