Trying to create a simple custom control in C# Winforms that inherits from Panel, but as soon as I change it to inherit from “Panel” instead of “UserControl” I get this error:

Here’s the code for the entire class:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SETPaint
{
public partial class Canvas : Panel
{
public Canvas()
{
InitializeComponent();
}
private void Canvas_Load(object sender, EventArgs e)
{
}
}
}
Delete the line ‘this.AutoScaleDimensions = …’ in your Designer.cs file (line 35 according to the exception). There’s probably another similar to ‘this.AutoScaleMode = .Font’ too.
This problem arises because you’ve used the Designer when the Control derived from UserControl, and it set some default properties in the InitializeComponent() method. Those properties are part of the UserControl base type, but not the Panel base type.
Since the IDE Designer can’t load the Designer.cs file to fix this problem, you need to do it manually.