This is a migrated thread and some comments may be shown as answers.

Listview selecting muliple indexes

1 Answer 158 Views
ListView
This is a migrated thread and some comments may be shown as answers.
HUAN
Top achievements
Rank 1
HUAN asked on 31 Jul 2013, 03:09 PM

Hello Telerik !
How to get Selected Index of items from Multi Select RadList View :(

  private void toolstripMenuCopy_Click(object sender, EventArgs e)
        {
            string temp = "";    
            
            for (int i = 0; i < radListView.SelectedItems.Count; i++)          
            {
 
                temp = temp + listItem[radListView.SelectedIndex].ToString() + Environment.NewLine; 
            }           
            Clipboard.SetText(temp);
        }
 
//listItem[] ={ "http://www.picasa.........", ...}


1 Answer, 1 is accepted

Sort by
0
Anton
Telerik team
answered on 02 Aug 2013, 09:22 AM
Hello Huan,

Thank you for writing.

In order to find selected indexes, you can use one of the following approaches:
string text="Selected items";
 
foreach (ListViewDataItem item in radListView1.SelectedItems)
{
    text += " " + radListView1.Items.IndexOf(item).ToString();
}
 
RadMessageBox.Show(text);
 
string text = "Selected items";
 
for (int i = 0; i < radListView1.Items.Count; i++)
{
    if (this.radListView1.Items[i].Selected)
    {
        text += " " + i;
    }
}
 
RadMessageBox.Show(text);

I hope this helps.

Regards,
Anton
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ListView
Asked by
HUAN
Top achievements
Rank 1
Answers by
Anton
Telerik team
Share this question
or