I have a class that I use to generate the custom buttons of my project in winforms, I simply define the font..color and in this way I use this custom button in all my forms.
The structure of files and directories that I have is this, within the solution I have this class
Content of the controls classCustomized
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace controlesPersonalizado
{
public class botonColor : Button
{
private static event EventHandler ColorCambiado;
private static Color fondo = Color.White;
private static Color colorfuente = Color.Black;
public static Color Fondo
{
get
{
return fondo;
}
set
{
fondo = value;
if (ColorCambiado != null) ColorCambiado(null, EventArgs.Empty);
}
}
public static Color ColorFuente
{
get
{
return colorfuente;
}
set
{
colorfuente = value;
if (ColorCambiado != null) ColorCambiado(null, EventArgs.Empty);
}
}
public botonColor()
{
Fondo = fondo;
ColorFuente = colorfuente;
this.BackColor = fondo;
this.ForeColor = colorfuente;
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
ColorCambiado += botonColor_ColorCambiado;
}
private void botonColor_ColorCambiado(object sender, EventArgs e)
{
this.BackColor = fondo;
this.ForeColor = colorfuente;
}
}
}
The problem I have is that sometimes (not always) when I open the form in design mode I get this error
I leave you some captures of the properties of the file
Sometimes recompiling the whole solution, closing the form and reopening it works but sometimes not. What can I do?
Thank you,