Create spaces between check boxes
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);
精彩评论