开发者

Get selected Row in ListView

I have a Listener on the DoubleClick event in a ListView. I have also act开发者_高级运维ivated FullRowSelect.

So when I double-click a row, only the value in the first column appears. I also tried it directly with SelectedItems.

Please help

Code:

private void lvRecipesPos_DoubleClick(object sender, EventArgs e)
{
    String s = "";

    foreach (ListViewItem item in lvRecipesPos.Items)
    {
        if (item.Selected == true)
        {
            s += item.Text.ToString();
        }
    }

    MessageBox.Show(s);
}


1) The ListView has a SelectedItems collection, so you don't have to iterate all items and check if they're selected.

2) Item has a SubItems collection which holds the texts for all sub items

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜