c# Checkedlistbox Multicolumn

纵然是瞬间 提交于 2019-11-28 08:19:50

问题


I have a checkedlistbox control in C#.

I want to know who to add multicolumns to it. The multicolumn property is set to true. I just want to know the coding to add 2 columns.

The code i have is

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;
    }
}

Can you please assist me on show me the correct way of doing this?


回答1:


Although CheckedListBox has MultiColumn property and you can set it to true, but it only arranges list of items in multiple columns flowing items top to down then right, based on height of control

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

So if you really need multiple column, consider using DatGridView or ListView that are real multi column controls.




回答2:


Setting the MultiColumn property to true doesn't allow you to add more columns manually. It just 'wraps' items to the next column instead of showing a vertical scrollbar once the items exceed the height of the CheckedListBox.

If you want a two column control, either use a grid control of some kind or a ListView control. By setting a ListView control's View property to View.Details, you can use it as a multicolumn 'grid'.



来源:https://stackoverflow.com/questions/32646757/c-sharp-checkedlistbox-multicolumn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!