开发者

how to check the list view items when we are using groups in list view

how to check the list view items when we are using list view group s...

I have list view in that i am using two groups ....

If i click on the list view first group item then click on the list view second group item

I want to do something ...

for that i have done below ...

private void lstviewCatgeories_SelectedIndexChanged(object sender, EventArgs e)
{
    var selectedItems = lstviewCatgeories.SelectedItems.Cast<ListViewItem>();
    var passed = (selectedItems
        .Select(l => l.Group.Name)
        .开发者_Go百科Distinct()
        .Count() == 2 && selectedItems.Count() == 2
    );
    if (passed)
    {
        var categoryItem = selectedItems
            .Where(l => l.Group.Name.ToLower() == "catgories")
            .Single();
        var priceItem = selectedItems
            .Where(l => l.Group.Name.ToLower() == "pricesrangegroup")
            .Single();


    // do something


    }
}

but the control does not goes in to if condition even if i select the first item in group 1 and then i select the second item in second group

but it does not working ..

would any one pls help on this...

many thanks

EDIT : I am getting count 1 at this line lstviewCatgeories.SelectedItems

would any one suggest any alternative solution for this.....


The main reason of this problem is that you not selecting multiple items. You can select multiple items by holding Ctrl key or you need to think about enabling CheckBox property to select multiple items with checkboxes.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜