How to set property isEnabled in each subitem butt

2019-08-26 12:47发布

I have listview. In this listview I have listview.item that contains button. I bind my listview to some datasource, so I have many buttons. How to disable all of this buttons?

http://pastebin.com/6MFDfX9S

2条回答
对你真心纯属浪费
2楼-- · 2019-08-26 13:32

If you have lots of buttons.. Use LINQ insted.

listview.Items.All(item =>{(your_obj)item.IsEnable=false; return true});
查看更多
在下西门庆
3楼-- · 2019-08-26 13:37

Looking at your code, besides binding to "Title", "Date", "DownloadedOrNot" and "Info" you can add another property and bind that to the IsEnable property of the buttons, like "IsEnable.

If you need to change the value of this property you can always traverse your ListView Items like this:

foreach (var item in listview.Items)
{
    (item as your_object).IsEnable = false;
}
查看更多
登录 后发表回答