Listview cannot add listviewitem

A

Alan T

I have a listview defined a coloumn at design time.

And the code I use to add a listviewitem:
ListViewItem lvi = new ListViewItem(user.Name);

lvi.Tag = (Object)user.Id;

lvUsers.Items.Add(lvi);



However, the listviewitem could not be added successfully.



If I removed the column settings, ie remove the columns at design time, then
the listviewitem can be added.



Why ?
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

IIRC the only time when y ou cannot use Items.Add is when you have the
control binded to some datasource.
Setting the columns have no impact on it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top