show selected value in listview c#

Asked

Viewed 1,294 times

1

Good morning. I have a listview with a list view. I wanted you to save the selected value when clicking on a certain line. How can I do?

  • What did you try?

  • listview.SelectedItems.Tostring();

  • Various events such as the click ...

  • My problem is that I’m using a listview from Infragistics

  • she has the Selectedindexchanged event ?

  • No. You have Itemactivated; Itemselectionchanged;

  • uses the Itemselectionchanged

Show 2 more comments

2 answers

3


If at any time you need to take the selected value from listview use the following code:

listView.SelectedItems[0].ToString();

If you need every time the selected item changes the value to be updated somewhere use the event Selectedindexchanged and it can use the same top code to pick up the value.

Remember
listview has multi-selection property (choose multiple items at the same time), make sure that this is what you want.

  • she’s using a third-party component, Infragistics, but it’s certainly something like =]

  • while typing I went to make sure in the code and did not see this comment, I will edit

  • 1

    I got it. It worked anyway ! :)

  • @Rovannlinhalis if you look at the editing history you’ll notice that I edited the question, but AP managed to do it the first way so I reversed the editing

  • 1

    I just made an observation, because I don’t know the control she’s using, and it could be different. =]

  • Yes, and thank you for informing me =P

  • I have this, as I do in this part, to select the item ? : if(listview.Items[j].)

Show 2 more comments

2

Using Infragistics, it may be possible to select the item on listvew as follows:

string text = listView.SelectedItems[0].Text.ToString();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.