update custom control during Design time

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.
 
A

--== Alain ==--

Ok, I found how to cope with it. SO do not pay attention to the previous
post.

AL.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top