Hack Forums
[C#] Can't add items in listview - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Can't add items in listview (/showthread.php?tid=4769234)



Can't add items in listview - Ðr1ps - Apr 8, 2015

Trying to add items to the listview but they just won't add no matter what I try.

This is the code currently
Code
var item = firstform.listView1.Items.Add(secondform.name.Text);
firstform.listView1.Items.Add("1");
item.SubItems.Add(secondform.name.Text);
item.SubItems.Add(secondform.map.Text);
item.SubItems.Add(secondform.players.Text);
item.SubItems.Add(secondform.ping.Text);

Am I missing anything? Thanks in advance.


* - xReaperGFX - Apr 8, 2015

(Apr 8, 2015 02:45 PM)Ðr1ps Wrote:  Trying to add items to the listview but they just won't add no matter what I try.

This is the code currently
Code
var item = firstform.listView1.Items.Add(secondform.name.Text);
firstform.listView1.Items.Add("1");
item.SubItems.Add(secondform.name.Text);
item.SubItems.Add(secondform.map.Text);
item.SubItems.Add(secondform.players.Text);
item.SubItems.Add(secondform.ping.Text);

Am I missing anything? Thanks in advance.

try declaring the item and assigning its properties, then adding to the listview.

Hint:Spoiler (Click to View)


* - Ðr1ps - Apr 8, 2015

It still won't add the items, unless it's adding them and it won't show them?

EDIT: It seems I'm not calling it properly from the first form as it works if I add the code on the first form where the listview is