I am trying to create a Categoría
for controles
(components) within a Control de Usuario
so that they are reflected in Propiedades
of Visual Studio, to make visible / not visible a PictureBox
, between other options, I did it like this:
bool _pictureBoxVisible = true;
Image _imagenPictureBox = Properties.Resources.Laimagen;
Color _colorFondoPanel = Color.Transparent;
Color _colorLetraLabel = Color.White;
Font _letraLabel = new Font("Tahoma", 14, FontStyle.Regular, GraphicsUnit.Pixel);
[Category("Configuración Control")]
[DefaultValue(true)]
[DesignOnly(true)]
[Description("Si es Verdadero (True), se muestra. Si es Falso (False) no mostrarlo.")]
[DisplayName("Mostrar/Ocultar")]
public bool PictureBoxVisible
{
get { return _pictureBoxVisible; }
set
{
_pictureBoxVisible = value;
if (_pictureBoxVisible)
this.picturebox_imagen.Visible = true;
else
this.picturebox_imagen.Visible = false;
}
}
Problems to solve
1- The property comes out correctly in the properties of the design, but when I change the property in the two controls, one works and another does not, and the design is shown correctly, but when the application is executed the% is shown
picturebox
even if the value of the property isfalse
How do I solve it?
I would also like to expose the following properties in the same category:
- 2: Move the PictureBox to the right side corner of the panel, when the panel changes its
Resize
. - 3: The Background Color of the Panel (BackColor)
- 4: Color of the Letter of the Label (ForeColor)
- 5: Source of the Label (Font)
- 6: The Picture and / or BackgroundImage of the PictureBox
But I do not know how to expose those other properties so that they come out like this:
How do I agree to create those system properties?
Environment: Visual Studio & .NET Netframework 4