如何在设计时间内看到自定义控件属性的变化
问题描述:
我有一个带有自定义属性bordercolor的自定义标签控件。
在VS2010的de属性窗口中的
你可以更改标签的bordercolor
自定义标签覆盖了onPaint活动
I have a custom label control with a custom property bordercolor.
in de property window of VS2010 you can change the bordercolor of the label
The custom label overrides the onPaint event
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, _BorderColor, 1, _
ButtonBorderStyle.Solid, _BorderColor, 1, ButtonBorderStyle.Solid, _BorderColor, 1, _
ButtonBorderStyle.Solid, _BorderColor, 1, ButtonBorderStyle.Solid)
End Sub
如果改变边框颜色VS2010并不会无变化地改变颜色形式类似于标签的标准backcolor属性。我首先要点击表单查看我所做的更改。
我怎样才能在VS2010的设计模式中看到变化
If a change the bordercolor VS2010 does not immidiatly change the color on the form like the standard backcolor property of the label. I first have to click on the form to see the change i've made.
How can i see the changes immidiatly in design mode in VS2010
答
在自定义属性设置器中,调用控件上的Invalidate()方法。
In the custom property setter, call the Invalidate() method on the control.
对于designTime,您必须重建控件以刷新它在设计师。
For designTime you have to rebuild the control to refresh it in the designer.