C#winforms如何为checkedlistbox中的复选框设置填充?

时间:2016-06-02 09:45:48

标签: c# winforms

enter image description here

在上图中,我想为checkedlistbox中的复选框设置填充(为RIGHT)。

2 个答案:

答案 0 :(得分:0)

您可以通过简单的解决方法来获得所需的结果,因为没有内置的功能:

private void Form1_Load(object sender, EventArgs e)
{
    CheckedListBox chkList = new CheckedListBox();
    chkList.BorderStyle = BorderStyle.None;
    chkList.Margin = new Padding(20, 3, 3, 3);
    chkList.Items.AddRange(new object[] { "A", "B", "C", "D", "E", "F" });
    FlowLayoutPanel fPanel = new FlowLayoutPanel();
    fPanel.Height = this.Height;
    chkList.BackColor = fPanel.BackColor = Color.White;
    fPanel.Controls.Add(chkList);

    this.Controls.Add(fPanel);
}

使用设计师可以采用相同的方法。

答案 1 :(得分:0)

CheckedListBox没有提供该功能(据我所知) 我能想到的唯一快速解决方案是在每个项目文本之前简单地添加2-3个空格。这是“脏”但它会起作用。
除此之外,您只能使用与DataGridView不同的内容。