菜单在订阅图片盒涂料事件时为什么会脱掉白色



我的表格具有MenuStripPictureBox。我使用以下代码订阅PictureBoxPaint事件:

private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
    pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
    // other code but the above line demonstrates the problem
}

由于某些原因,这会导致MenuStrip变为白色 - 直到我徘徊在盘旋上之前,我才能看到文本,即使PictureBox完全没有重叠MenuStrip。我可以在上面的函数末尾放置一个menuStrip1.Update(),但这会导致其他问题。

,而不是在事件中直接分配给PictureBox,请使用提供的PaintEventArgs进行任何图纸。

    private void pictureBox1_Paint(object sender, PaintEventArgs e)
    {
        e.Graphics.Clear(Color.Gray);
    }

最新更新