如何改变的CheckedListBox项目的垂直空间

如何改变的CheckedListBox项目的垂直空间

本文介绍了如何改变的CheckedListBox项目的垂直空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要更改 CheckedListBox 项目的垂直空间,以便它们与另一侧的文本框相匹配:

I need to change the vertical space for CheckedListBox items so they fit with the text boxes on the other side:

>
如何做?

How to do this ?

做了一些研究后,我发现 CheckedListBox 继承了 ListBox 它必须有其公共属性 ItemHeight ,但由于某种原因它不

After doing some research I found out that CheckedListBox inherits ListBox, so it must have its public property ItemHeight, but for some reason it doesn't

我试过这: p>

I tried this :

ListBox l = CheckedList as ListBox;
        l.ItemHeight = 30;

但不起作用

推荐答案

CheckedListBox的ItemHeight属性的默认实现是

The default implementation of ItemHeight property of CheckedListBox is,

public override int ItemHeight {
        get {
            // this should take FontHeight + buffer into Consideration.
            return Font.Height + 2;
        }
        set {
        }
    }



you can cleanly override this property in a new class.

public sealed class  MyListBox:CheckedListBox
    {
        public MyListBox()
        {
            ItemHeight = 30;
        }
        public override int ItemHeight { get; set; }
    }

这应该允许您设置自己的ItemHeight。

this should allow you to set your own ItemHeight.

>

这篇关于如何改变的CheckedListBox项目的垂直空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 23:23