Delphi中的THeaderControl是否有用途 [英] Is there a use for THeaderControl in Delphi

查看:154
本文介绍了Delphi中的THeaderControl是否有用途的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在为我的网站 LearnDelphi.tv 制作有关使用delphi组件的视频。我正在寻找涵盖THeaderControl的方法,但找不到任何用途-现在是否不需要此组件-被其他组件(例如TListView(具有报表viewstyle)超越)还是有某种我忽略的使用方法?



编辑:
我在THeaderControl上为我的一部商业视频录制了一个片段,但我决定发布这一小节(每6分钟20分钟)小时)。在 YouTube 上观看。感谢所有贡献者。

解决方案

通常: THeaderControl 可以用作表格数据的标题。当然,通常为此使用列表视图。但是对于每个列中不同组件的异类布局(使用列表视图或类似视图很难创建),或者甚至为每个列完成不同的布局,标头控件也可能很有用。它只是在需要的地方提供更大的灵活性。与 TPageControl 进行比较,它比 TTabControl 提供更大的灵活性。



  TPlanGridHeader = class(TCustomHeaderControl)
private
FSectionWidth:整数;
过程SetSectionWidth(Value:Integer);
过程WMMouseMove(var消息:TWMMouseMove);消息WM_MOUSEMOVE;
受保护的
函数CreateSection:THeaderSection;覆盖
过程SectionResize(Section:THeaderSection);覆盖
过程SectionTrack(Section:THeaderSection; Width:Integer;
State:TSectionTrackState);覆盖
属性SectionWidth:整数读取FSectionWidth写入SetSectionWidth;
public
过程AddSection(const AText,AHint:String);
构造函数Create(AOwner:TComponent);覆盖
结尾;


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.

解决方案

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;

这篇关于Delphi中的THeaderControl是否有用途的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆