【问题标题】:Checkedlistbox Multicolumn选中列表框多列
【发布时间】:2015-12-15 07:01:09
【问题描述】:

我在 Windows 窗体中有一个 CheckedListBox 控件。

我想知道向谁添加多列。 MultiColumn 属性设置为 true。 我只想知道添加2列的编码。

我的代码是

while (true)
{
    data = SDK.GetNext("ACCHISTL", 6);
    document_details = data.Split('|');
    if (document_details[0] == "0")
    {
        if (document_details[3] == Document_nr)
        {
            lbLines.Items.su(document_details[4] + " -> " + document_details[14],true);
        }
        else
        {
            break;
        }
    }
    else
    {
        break;
    }
}

你能帮我告诉我这样做的正确方法吗?

【问题讨论】:

  • 旁注:将running = false 更改为breakwhile(running) 更改为while(true)
  • @DmitryBychenko 坦克你伙计。我已经改变了:)

标签: c# .net winforms multiple-columns checkedlistbox


【解决方案1】:

使用具有所需列数和行数的 TableLayoutPanel 并在其中放置复选框。

【讨论】:

    【解决方案2】:

    虽然CheckedListBox 具有MultiColumn 属性并且您可以将其设置为true,但它仅根据控件的高度从上到下然后右排列多个列中的项目列表

    ■ 1         ■ 5
    ■ 2         ■ 6
    ■ 3         ■ 7
    ■ 4
    

    因此,如果您确实需要多列,请考虑使用真正的多列控件DatGridViewListView

    【讨论】:

    • 感谢您的信息 :) 我已将其更改为 DataGridView,它现在可以 100% 工作
    【解决方案3】:

    MultiColumn 属性设置为true 不允许您手动添加更多列。它只是将项目“包装”到下一列,而不是在项目超过 CheckedListBox 的高度时显示垂直滚动条。

    如果您想要一个两列控件,请使用某种网格控件或ListView 控件。通过将ListView 控件的View 属性设置为View.Details,您可以将其用作多列“网格”。

    【讨论】:

    • 我已将我的 CheckboxList 更改为 ListView。会看看它是否有效,然后让你知道。感谢您的帮助
    • 是的,让我知道情况如何。我也一直在试验 CheckedListBoxes。
    猜你喜欢
    • 2012-12-25
    • 1970-01-01
    • 2011-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-04
    相关资源
    最近更新 更多