locked
Get the value of an item of ListBox by index RRS feed

  • Question

  • Hello,

    I want to get from a Listbox the value of an item, having the index. I wrote:

    string link = listbox.Items[2].ToString();

    But this doesn't return the value, how can I do that?

    Thanks.

    Friday, December 28, 2012 4:21 PM

Answers

  • Then, use ItemsSource or DataContext to bring the model and get the entire entity. You can use foreach iterator here.

    Regards.


    - Chris.

    • Marked as answer by Moonstone94 Friday, December 28, 2012 7:46 PM
    Friday, December 28, 2012 7:19 PM

All replies

  • Hi Rocker75,

    you can try this:

    string link = listbox.SelectedValue.ToString();

    Hope it helps.

    Regards.


    - Chris.

    Friday, December 28, 2012 6:05 PM
  • Thanks for the answer but I don't want the SelectedValue, I need the value of Items[i] where "i" is not the selected value.
    Friday, December 28, 2012 7:11 PM
  • Then, use ItemsSource or DataContext to bring the model and get the entire entity. You can use foreach iterator here.

    Regards.


    - Chris.

    • Marked as answer by Moonstone94 Friday, December 28, 2012 7:46 PM
    Friday, December 28, 2012 7:19 PM