I have a strange visual error in VS 2019 with a windows forms project:
I started to remake an example project of a modern, dark UI from a YT video: https://www.youtube.com/watch?v=vYDyGxoq9JU
I wanted to have rounded corners in panels and buttons and for that I added a new class SButton:
namespace Dashboard
{
public class SButton : Button
{
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn
(
int nLeftRect,
int nTopRect,
int nRightRect,
int nBottomRect,
int nWidthEllipse,
int nHeightEllipse
);
protected override void OnPaint(PaintEventArgs e)
{
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 12, 12));
}
}
}
I did the same with a new class for panels with rounded corners. I used the new SButton in both ways: generating some just with code and some by draging them from toolbox. They work, but appear with graphic elements of the buttons on the left (which are normal buttons, made "by mouse"), and the top bar of the property window. Appearance changes when hovering over the button.
The 3 controls on the right are SButton. Two of them show strange duplicated graphic elemenst from elswehere.
This behavior ist still there when compiling the app.
When I open this project on a different computer who has a slightly different version of VS 2019, the problem is the same. You can download the project (260kb) here, if You are curious.
I find this really strange and do not know how to solve it, except trying to start over from zero again.