Can anyone tell me why ListViewGroup lvg nor ListViewItem lvi show up on playerlistbox. I do believe that a listviewgroup does not show if it's itemcount == 0, if that helps. c# coding. /*Player-Jersey-Position-Onice*/
ListView lv = playerlistbox;
ListViewGroup lvg = null;
MessageBox.Show("Adding player to list");
for(int i = 0;i < lv.Groups.Count;i++)
{
try
{
teamdata groupt = (teamdata)lv.Groups[i].Tag;
if(groupt == t)
{
lvg = lv.Groups[i];
lv.Groups.Remove(lv.Groups[i]);
}
}
catch{}
}
if(lvg == null)
{
MessageBox.Show("Creating new group");
lvg = new ListViewGroup();
lvg.Name = t.city+" "+t.name;
lvg.Header = t.city+" "+t.name;
lvg.Tag = t;
lvg.HeaderAlignment = HorizontalAlignment.Left;//maybe?
}
MessageBox.Show("Clearing Items");
lvg.Items.Clear();
for(int i = 0;i < t.playercount;i++)
{
player n = t.players[i];
ListViewItem lvi = new ListViewItem();
lvi.Group = lvg;
lvi.Text = n.first+" "+n.last;
lvi.Name = n.first+" "+n.last;
lvi.SubItems.Add(n.number.ToString());
lvi.SubItems.Add(n.position);
if(n.Onice)
lvi.SubItems.Add("Yes");
else
lvi.SubItems.Add("No");
lvi.Tag = n;
lvg.Items.Add(lvi);
MessageBox.Show("Added new player");
}
lv.Groups.Add(lvg);
} those messagebox's are for debugging purposes ignore them, but do note that all 4 messagebox's are shown. t is a teamdata variable. also, when i add it to the listview's items rather than the listviewgroup's items, it shows, and it shows under a listviewgroup labeled "Default".