Jump to content
SubSpace Forum Network

Recommended Posts

Posted (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 by tcsoccerman
Posted

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

 

*joke*

maybe you should hire

http://img394.imageshack.us/img394/9141/trainerbattle10yr.png

 

then

 

*/joke*

Guest
This topic is now closed to further replies.
×
×
  • Create New...