【问题标题】:How can i override the ItemHeight property of listbox?如何覆盖列表框的 ItemHeight 属性?
【发布时间】:2011-03-30 05:06:26
【问题描述】:

我想设置 CheckedListBox 的 itemHeight 属性。但它没有 ItemHeight 属性。因为 CheckedListBox 是从 ListBox 类派生的,我想覆盖 ListBox 类的 ItemHeight 属性。谁能告诉我解决办法?

【问题讨论】:

  • @sanjeevakumar : 我想设置 CheckedListBox 的 ItemHeight 属性
  • 检查给定 MSDN 文档中的代码示例,它就是这样做的。

标签: .net windows winforms


【解决方案1】:

您可以从 CheckedListBox 派生一个类并覆盖 ItemHeight 以返回 base.ItemHeight+<value by which you wish to increase the height>。然后,您将不得不使用这个扩展 CheckedListBox 的新类。
此外,您可以使用属性 O​​wnerDrawVariable 使 CheckedListBox 所有者绘制并使用 MeasureItem。

详情见 http://msdn.microsoft.com/en-us/library/system.windows.forms.checkedlistbox.measureitem.aspx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-02
    • 2011-11-06
    • 1970-01-01
    • 2015-01-08
    相关资源
    最近更新 更多