在我的項目中,我使用鍵值對string
和elementId
作出列表。製作列表的原因是因爲我想在代碼中稍後將所有項目添加到checkedListBox
。c#多列列校驗列表框中的KeyValuePair列表
List<KeyValuePair<string, ElementId>> kvPairs = new List<KeyValuePair<string, ElementId>>();
當我有我的元素集合,我加入元素名稱和元素ID爲鍵值對:
foreach (Element viewElement in viewCollector)
{
kvPairs.Add(new KeyValuePair<string, ElementId>(viewElement.Name, viewElement.Id));
}
我想接下來的事情,就是添加這些關鍵-value配對到checkedListBox
,其中名稱被添加到elementId
的單獨列中。
但我似乎無法找到在哪裏/如何添加第二列。在checkedListBox.Items.Add()
中似乎沒有超載方法來寫入多個列。
編輯:
使用WinForms。
而且整個checkedListBox.MultiColumn
似乎沒有意義,如果沒有辦法定義列。我真的很困惑。
Winforms,WPF,...? – Jim
@Jim對不起,使用Winforms – Dante1986
這不能用'CheckedListBox'完成,可以考慮使用* DataGridView *或* ListView *。 – Jim