.net - C#: Problem with selecting different items after using ListView.SelectedItems[0] -


I have a problem, I am using the method in the list view list. The selected [0] logic in a function selected to return the selected ListViewItem to the selection, when selected, displays the text of the item in the text box, this method is set on the Listview_SelectedIndexChanged event. The problem is that when I have selected a different item, which was already done before the selection, an error occurred,

ArgumentOutRangeException was unrestricted invalidArgument = '0' The value 'index' is not valid for the parameter name: index

Why is it causing the error when I want to return the selected items from my current list to my listview? It is only after selecting one and only after selecting the second item.

Here is an event:

  Private zeros lvMyItems_SelectedIndexChanged (Object Sender, EventArgs e) {// Return current item ShowItem (lvMyItems.SelectedItems [0]); // here is error}  

And here is the method that is calling it:

  Private zero-list {ListViewItem MyItem} Text and sub-text in the method Two text boxes of my list view items in TxtItemName.Text = MyItem.Text; TxtItemNickName.Text = MyItem.SubItems [1]. Text; } "No selection" is also possible situation.  

selectedItems.Count> = 1 before indexing item number 0.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -