ListView.ItemCheck与ListView.ItemChecked在.NETItemCheck、ListView、NET、ItemChecked

2023-09-04 08:44:15 作者:剧终

什么是,在ListView之间的差异ItemCheck和ListView ItemChecked在.NET事件?

What is the difference between the ListView.ItemCheck and ListView.ItemChecked events in .NET?

推荐答案

ItemCheck 事件被触发时,一个项目的选中状态的即将改变的,让你检查旧的和新的价值,如果你想(通过分配的EventArgs参数的NewValue属性)取消更改。 ItemChecked 被触发的的检查后(或取消)完成的。

The ItemCheck event is triggered when the checked state of an item is about to change, allowing you to examine the old and new value, and to cancel the change if you wish (by assigning the NewValue property of the eventargs parameter). ItemChecked is triggered after the check (or uncheck) is completed.

code样品:

Code sample:

private void ListView_ItemCheck(object sender, ItemCheckEventArgs e)
{
    // the checked state of an item is about to change
    if (e.NewValue == CheckState.Checked)
    {
        // perform some check if this is allowed, and if not...
        e.NewValue = e.CurrentValue;
    }
}

private void ListView_ItemChecked(object sender, ItemCheckedEventArgs e)
{
    // the checked state of an item has changed
}
 
精彩推荐
图片推荐