开发者

Create spaces between check boxes

开发者 https://www.devze.com 2023-01-01 22:29 出处:网络
I have a checkedlistbox and when i populate it i want to have an empty space between each check box. i can create them with an empty string but the check box is s开发者_StackOverflow中文版till there.

I have a checkedlistbox and when i populate it i want to have an empty space between each check box. i can create them with an empty string but the check box is s开发者_StackOverflow中文版till there. can anyone please help me.

thank you


Assuming you are using .NET C# winforms...

You can inherit this control, and override the property .ItemHeight as follows:

private class OverriddenCheckedListBox : CheckedListBox
{
    public override int ItemHeight { get; set; }
}

Place one of these controls on your form, and set the property to a height that suits the amount of space you desire. (If you want it to show up in the toolbox you'll need to create it as a user control.) Here is an example:

OverriddenCheckedListBox ochkListBox = new OverriddenCheckedListBox();
ochkListBox.Location = new Point(0, 0);
ochkListBox.Dock = DockStyle.Fill;
ochkListBox.Items.Add("Alpha");
ochkListBox.Items.Add("Beta");
ochkListBox.Items.Add("Charlie");
ochkListBox.Items.Add("Delta");
ochkListBox.Items.Add("Epsilon");
ochkListBox.ItemHeight = 30; // This is your row height
this.Controls.Add(ochkListBox);
0

精彩评论

暂无评论...
验证码 换一张
取 消