使用此代码:
Dictionary<int, String> PlatypusAccountsDict = PlatypusSetupData.getPlatypusAccountsForCustomer(kvp.Key);
foreach (KeyValuePair<int, string> entry in PlatypusAccountsDict) {
int PlatypusAccountNumber = entry.Key;
string PlatypusAccountName = entry.Value;
ListViewGroup PlatypusAccountGroup = new ListViewGroup(PlatypusAccountName, HorizontalAlignment.Left)
{
Tag = PlatypusAccountNumber,
Header = PlatypusAccountName
};
listViewCustomerDuckBillAccountsClients.Groups.Add(PlatypusAccountGroup);
. . .
...我可以逐步查看“条目”中有值,但是我的ListView中没有添加任何组 - 在此代码运行后它仍然是裸体的jaybird。我知道这个问题有三个可能的原因:1)我忘记了一步。 2)来自太阳的巨大EMP已经破坏了某些东西,或3)我不知道的其他东西。
在调用Groups.Add(PlatypusAccountGroup)后添加此测试代码:
ListViewItem listViewItem1 = new ListViewItem(new string[] { "Banana", "a" }, -1, Color.Empty, Color.Yellow, null);
ListViewItem listViewItem2 = new ListViewItem(new string[] { "Cherry", "v" }, -1, Color.Empty, Color.Red, new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((System.Byte)(0))));
ListViewItem listViewItem3 = new ListViewItem(new string[] { "Apple", "h" }, -1, Color.Empty, Color.Lime, null);
ListViewItem listViewItem4 = new ListViewItem(new string[] { "Pear", "y" }, -1, Color.Empty, Color.FromArgb(((System.Byte)(192)), ((System.Byte)(128)), ((System.Byte)(156))), null);
listViewItem1.Group = PlatypusAccountGroup;
listViewItem2.Group = PlatypusAccountGroup;
listViewItem3.Group = PlatypusAccountGroup;
listViewItem4.Group = PlatypusAccountGroup;
this.listViewPlatypusAccounts.Items.AddRange(new ListViewItem[] {listViewItem1,
listViewItem2,
listViewItem3,
listViewItem4});
...添加我想要/期望的组,但不会在其下添加任何水果项。