A
--== Alain ==--
Hi,
I still have problem updating my custom control at design time.
When i change a property of my custom control in the property window, i
would like to see this change immediately on my custom control at the
design time.
Unfortunately, my custom control does not refresh at design time when a
property is changed.
Here is my custom control class extract :
namespace MyComponent
{
public partial class Frame : UserControl
{
private EventHandler HandlerColorChanged;
public Frame()
{
InitializeComponent();
}
private CGridLine m_GridLines= new CGridLine();
[Category("Appearance")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Description("Setup Style, Type and Color of gridlines to draw.")]
[TypeConverter(typeof(CGridLineConverter))]
public CGridLine GridLines
{
get
{
return this.m_GridLines;
}
set
{
this.m_GridLines = value;
this.Invalidate();
}
}
protected override void OnPaint(PaintEventArgs e)
{
if (this.m_GridLines.Lines != GridLine.None)
{
Pen myPen = new Pen(this.m_GridLines.Color);
e.Graphics.DrawRectangle(myPen, new
Rectangle(0,0,this.Width-1,this.Height-1));
}
}
}
}
the property GridLines is based on the following class :
public class CGridLine
{
public event EventHandler ColorChanged;
[RefreshProperties(RefreshProperties.Repaint)]
[NotifyParentProperty(true)]
[DefaultValue(typeof(Color), "ActiveBorder")]
public Color Color
{
get
{
return this.m_GridLinesColor;
}
set
{
if (this.m_GridLinesColor != value)
{
this.m_GridLinesColor = value;
OnColorChanged(EventArgs.Empty);
}
}
}
protected virtual void OnColorChanged(EventArgs e)
{
if (ColorChanged != null)
{
ColorChanged(this, e);
}
}
}
thanks for help,
Al.
I still have problem updating my custom control at design time.
When i change a property of my custom control in the property window, i
would like to see this change immediately on my custom control at the
design time.
Unfortunately, my custom control does not refresh at design time when a
property is changed.
Here is my custom control class extract :
namespace MyComponent
{
public partial class Frame : UserControl
{
private EventHandler HandlerColorChanged;
public Frame()
{
InitializeComponent();
}
private CGridLine m_GridLines= new CGridLine();
[Category("Appearance")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Description("Setup Style, Type and Color of gridlines to draw.")]
[TypeConverter(typeof(CGridLineConverter))]
public CGridLine GridLines
{
get
{
return this.m_GridLines;
}
set
{
this.m_GridLines = value;
this.Invalidate();
}
}
protected override void OnPaint(PaintEventArgs e)
{
if (this.m_GridLines.Lines != GridLine.None)
{
Pen myPen = new Pen(this.m_GridLines.Color);
e.Graphics.DrawRectangle(myPen, new
Rectangle(0,0,this.Width-1,this.Height-1));
}
}
}
}
the property GridLines is based on the following class :
public class CGridLine
{
public event EventHandler ColorChanged;
[RefreshProperties(RefreshProperties.Repaint)]
[NotifyParentProperty(true)]
[DefaultValue(typeof(Color), "ActiveBorder")]
public Color Color
{
get
{
return this.m_GridLinesColor;
}
set
{
if (this.m_GridLinesColor != value)
{
this.m_GridLinesColor = value;
OnColorChanged(EventArgs.Empty);
}
}
}
protected virtual void OnColorChanged(EventArgs e)
{
if (ColorChanged != null)
{
ColorChanged(this, e);
}
}
}
thanks for help,
Al.