Большой красный крест на кнопках winform C#
I am working on windows application and in one of my system it shows red big cross on buttons only when I am using application for long time. I am using paint event of button for giving it 3D effect. For that I am using following code: [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")] private static extern IntPtr CreateRoundRectRgn ( int nLeftRect, // x-coordinate of upper-left corner int nTopRect, // y-coordinate of upper-left corner int nRightRect, // x-coordinate of lower-right corner int nBottomRect, // y-coordinate of lower-right corner int nWidthEllipse, // height of ellipse int nHeightEllipse // width of ellipse ); private void button1_Paint(object sender, PaintEventArgs e) { var button1 = sender as Button; button1.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(2, 2, button1.Width, button1.Height, 2, 2)); ControlPaint.DrawBorder3D(e.Graphics, ((Control)sender).ClientRectangle, Border3DStyle.Raised); } Please provide solution to this porblem. Thanks in Advance.
Что я уже пробовал:
Я попытался избавиться от графического объекта в конце события paint, но он вызывает ошибку нулевой ссылки.