我正在 Visual Studio 2017 中創(chuàng)建一個 winforms 應(yīng)用程序,我正在使用 List<KeyValuePair<string, string>>數(shù)據(jù)示例如下: List<KeyValuePair<ABC, 123>> List<KeyValuePair<ABC, 456>> List<KeyValuePair<ABC, 789>> List<KeyValuePair<DEF, 123>> List<KeyValuePair<DEF, 233>>我嘗試在 ListView 中顯示它,在那里我想要這樣的東西:美國廣播公司123456789防御工事123233其中 ABC 和 DEF 只能選擇。我嘗試編寫代碼來執(zhí)行此操作,但不幸的是它只顯示 ABC 和 DEF 而沒有子項。我寫的代碼是: workOrderClusters = GetItac.FilterWorkOrderClusters(); // GetItac.FilterWorkOrderClusters() is a List<KeyValuePair<string,string>> string current; string previous, foreach (var workOrderCluster in workOrderClusters) { current = workOrderCluster.Key; if (current != previous) { var listViewItem = new ListViewItem(workOrderCluster.Key); foreach (var cluster in workOrderClusters) { if (cluster.Key == current) { listViewItem.SubItems.Add(cluster.Value); } } } previous = current; listView1.Items.Add(listViewItem);我的問題是,無論如何都可以按預(yù)期顯示 ListView 嗎?
- 1 回答
- 0 關(guān)注
- 235 瀏覽
添加回答
舉報
0/150
提交
取消