Checkedlistbox Multicolumn
Asked Answered
S

3

7

I have a CheckedListBox control in Windows Forms.

I want to know who to add multi-columns 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?

Svetlana answered 18/9, 2015 at 7:57 Comment(2)
Side note: change running = false to break and while(running) to while(true)Hummock
@DmitryBychenko Tank you man. I have change that :)Svetlana
A
8

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.

Accouter answered 18/9, 2015 at 8:15 Comment(1)
Thank you for your information :) I have change it to a DataGridView and it is working 100% nowSvetlana
I
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'.

Iniquitous answered 18/9, 2015 at 8:13 Comment(2)
I have change my CheckboxList to a ListView. Will see if it works then let you know. Thank you for your helpSvetlana
Yeah, let me know how that goes. I've been experimenting with CheckedListBoxes too.Iniquitous
R
0

Use a TableLayoutPanel with desired number of columns and rows and put the checkboxes in there.

Ruelas answered 31/3, 2021 at 20:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.