我找不到错误code.a图片框不更新

I can not find the error in the code.a picture Box does not update

我正在创建一个软件,其中 pictureBox2 会根据单击 pictureBox1 的像素颜色进行更新。

已经尝试使用 refresh(),但 pictureBox2 没有改变。

private void PictureBox1_MouseUp(object sender, MouseEventArgs e)
{
    Bitmap b = new Bitmap(pictureBox1.Image);
    color = b.GetPixel(e.X, e.Y); // Color

    solidColor = new Bitmap(pictureBox2.Width, pictureBox2.Height, PixelFormat.Format24bppRgb); //Image
    using (Graphics grp = Graphics.FromImage(solidColor))
    {
        SolidBrush co = new SolidBrush(color);
        grp.FillRectangle( co, 0, 0, pictureBox2.Width, pictureBox2.Height);
    }

    pictureBox2.Image = solidColor;
}

我可以通过这样做来解决这个问题。

private void PictureBox1_Click(object sender, EventArgs e)
        {

            Bitmap b = new Bitmap(pictureBox1.Image);
            MouseEventArgs me = (MouseEventArgs)e;
            Point cord= me.Location;
            color = b.GetPixel(cord.X,cord.Y); 

            solidColor = new Bitmap(pictureBox2.Width, pictureBox2.Height, PixelFormat.Format24bppRgb);
            using (Graphics grp = Graphics.FromImage(solidColor))
            {

                SolidBrush co = new SolidBrush(color);
                grp.FillRectangle(co, 0, 0, pictureBox2.Width, pictureBox2.Height);

            }

            pictureBox2.Image = solidColor;

        }
```c#