我有一个自定义列表视图,我想在 OnDrawSubItem 函数中调试一些显示 MessageBox 的东西。我预计一些 GUI 冻结试图重新绘制该项目。奇怪的是,当我单击子项(在 MessageBox 之后)时,CPU 会达到 100%。有人可以解释一下这是什么循环吗?
class ListViewEx : ListView
{
    public ListViewEx()
    {
        this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);
    }
    protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
    {
        e.DrawDefault = true;
    }
    protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
    {
        MessageBox.Show("test");
        e.DrawDefault = true;
    }
}
编辑
如果我对按钮的绘制事件做同样的事情,我的 CPU 不高(只是一些重复的 MessageBox)
    private void btnTest_Paint(object sender, PaintEventArgs e)
    {
        MessageBox.Show("test");
    }
我知道在绘制事件中显示 mbox 是不对的。我对我的两个示例中的不同行为感到好奇。