当存在组时,列表视图控件绘制不正确

发布于 2024-12-16 02:22:36 字数 230 浏览 5 评论 0原文

我正在尝试使用列表视图组,结果发现应用程序启动时控件显示不正确。

原始表单

一旦我调整表单大小,它就会正确显示:

Resized form

我不明白发生了什么。谁能解释一下吗?

I was experimenting with list view groups, and it turns out the control displays incorrectly when the application starts.

Original form

As soon as I resize the form it displays correctly:

Resized form

I do not understand what is happening. Can anyone explain?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜雨飘雪 2024-12-23 02:22:36

这是我重现的 Delphi 控件中的一个错误。我还不确定是什么原因导致了这个错误。我已将其提交给 Quality Central,名称为 QC#101104

我找到了一个简单的解决方法,将以下代码添加到表单的 OnShow 事件中。

ListView1.Align := alNone;
ListView1.Align := alClient;

下面的 DFM 文件足以说明该问题:

object MyForm: TMyForm
  Left = 0
  Top = 0
  ClientHeight = 300
  ClientWidth = 635
  object ListView1: TListView
    Left = 200
    Top = 96
    Width = 250
    Height = 150
    Align = alClient
    Columns = <
      item
        Caption = 'Column'
      end>
    Groups = <
      item
        Header = 'Group header'
        GroupID = 0
      end>
    Items.ItemData = {
      052A0000000100000000000000FFFFFFFFFFFFFFFF0000000000000000000000
      000854006800650020006900740065006D00}
    GroupView = True
    ViewStyle = vsReport
  end
end

事实证明,解决该问题的另一种方法是移动 DFM 文件中的 ViewStyle 条目,使其出现在 Items条目。因此,解决该问题的另一个方法是在运行时添加项目。事实上,这可能解释了为什么这个错误还没有被发现,因为我打赌绝大多数列表视图代码在运行时添加了项目。

It's a bug in the Delphi control which I have reproduced. I'm not sure yet what causes the bug. I have submitted this to Quality Central as QC#101104.

I found a simple workaround by adding the following code to the form's OnShow event.

ListView1.Align := alNone;
ListView1.Align := alClient;

The following DFM file is enough to demonstrate the problem:

object MyForm: TMyForm
  Left = 0
  Top = 0
  ClientHeight = 300
  ClientWidth = 635
  object ListView1: TListView
    Left = 200
    Top = 96
    Width = 250
    Height = 150
    Align = alClient
    Columns = <
      item
        Caption = 'Column'
      end>
    Groups = <
      item
        Header = 'Group header'
        GroupID = 0
      end>
    Items.ItemData = {
      052A0000000100000000000000FFFFFFFFFFFFFFFF0000000000000000000000
      000854006800650020006900740065006D00}
    GroupView = True
    ViewStyle = vsReport
  end
end

It turns out that another way to resolve the problem is to move the ViewStyle entry in the DFM file so that it appears before the Items entry. So yet another workaround for the problem would be to add the items at runtime. In fact this probably explains why this bug has not been found since I bet that the overwhelming majority of list view code adds the items at runtime.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文