Windows Phone Developers

Showing posts with label C# Listbox Selected Item. Show all posts
Showing posts with label C# Listbox Selected Item. Show all posts

Monday, April 19, 2010

How to iterate MultiSelect ListBox using C# (.NET)

C# - Get Selected Values from MultiSelect ListBox

Here is a way of retrieving the selected values of Multiselect listbox

for (int i1 = 0; i1 < listBox1.SelectedItems.Count; i1++)
            {
                DataRowView D1 = listBox1.SelectedItems[i1] as DataRowView;

                MessageBox.Show(D1[1].ToString());
            }
The above code uses SelectedItems collection to retrieve information Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Saturday, April 17, 2010

How to get the selected value of listbox using C# code

The following code retrieves the value of listbox and the accompanying text

private void listBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            MessageBox.Show(listBox1.Text);
            MessageBox.Show(listBox1.SelectedValue.ToString());
        }



The above method retrieves the displaytext (DisplayMember) and the selected value (DisplayValue) from the selected item of listbox Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon