开发者

ListView - Details View: Does 'this' belong to 'this'?

In Details View for the ListView Co开发者_运维百科ntrol, how can I do something like this, in the simplest way?

if(listView1.SelectedItem belongs to listView1.Groups["BaseballGroup"])
{
   MessageBox.Show("The selected item is inside the Baseball Group");
}


Actually there's no property SelectedItem but a list of SelectedItems, then:

if(listView1.SelectedItems[0].Group == listView1.Groups["BaseballGroup"])
{
   //...
}

N.B.
Check if something is selected (SelectedItems.Count > 0) to do SelectedItems[0] safely.


Perhaps you could try

listView1.Groups["BaseballGroup"].Contains(listView1.SelectedItem.ToString())

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜