tcsoccerman Posted March 22, 2008 Report Posted March 22, 2008 (edited) 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". Edited March 22, 2008 by tcsoccerman
Drake7707 Posted March 22, 2008 Report Posted March 22, 2008 isn't databinding (using the DataSource properties) much easier to link an array to a listview ? (i've only used C# with ASP.Net so i'm not entirely sure that works everywhere Spoiler! --Click here to view--*joke*maybe you should hirehttp://img394.imageshack.us/img394/9141/trainerbattle10yr.png then */joke*
tcsoccerman Posted March 23, 2008 Author Report Posted March 23, 2008 idk, i'm just worried about this bug atm. for now i suppose i'll develop without the gruops.
tcsoccerman Posted March 23, 2008 Author Report Posted March 23, 2008 oh snap i fixed it. i said screw it and instead of adding it to the group, added it to the listview altogether. then because of this line lvi.group = lvg; it worked. w.e.
Recommended Posts