Resize a ListView depending on how many items?

Posted by Dodi300 on Stack Overflow See other posts from Stack Overflow or by Dodi300
Published on 2010-03-29T21:40:49Z Indexed on 2010/03/29 21:43 UTC
Read the original article Hit count: 371

Filed under:
|
|
|
|

Hello. How can I resize the height of a ListView depending on how many items are in that ListView? I'm trying to get the text of an item which is clicked, however whenever the user clicks on a space which has no item, there's an error. The exact error is:

InvalidArgument=Value of '0' is not valid for 'index'. Parameter name: index.

I'm using the code:

label14.Text = myListView1.SelectedItems[0].Text.ToString();

I figured that removing the space below the items will solve this problem. Thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about listview