开发者

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

开发者 https://www.devze.com 2023-02-12 03:11 出处:网络
In Details View for the ListView Co开发者_运维百科ntrol, how can I do something like this, in the simplest way?

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

精彩评论

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