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())
精彩评论