I have CustomForm inherited from Form which implements a boolean property named Prop. The forms I'll be using will inherit from CustomForm. This property will do some painting and changes (if it's enabled) to the form. However, this is not working as it should, the VS IDE designed is not being refresh to show the changes. But if I press Ctrl+Shift+B (Menu: Build » Build Solution) the VS IDE will refresh, the form designer will even disappear for a split second and will redraw itself with the new changes applied.
So, is there a way, by code, to force the VS IDE designer to refresh itself just like it happens when I build the solution? If so, I could add that code to the Prop set accessor and my problem was gone.
Note that I've tried to call Invalidate(), Refresh() and Update. But none of them seemed to fix the problem...
Here's a little insight on my real problem. My code goes something like this:
internal class MyForm : Form {
private FormBorderStyle formBorderStyle;
private bool enableSkin;
[DefaultValue(false)]
public bool EnableSkin {
get {
return enableSkin;
} set {
enableSkin = value;
if(enableSkin) {
BackColor = Color.Lime;
MaximizedBounds = Screen.GetWorkingArea(this);
TransparencyKey = Color.Lime;
base.FormBorderStyle = FormBorderStyle.None;
} else {
BackColor = SystemColors.Control;
MaximizedBounds = Rectangle.Empty;
TransparencyKey = Color.Empty;
base.FormBorderStyle = FormBorderStyle;
}
}
}
[DefaultValue(FormBorderStyle.Sizable)]
public new FormBorderStyle FormBorderStyle {
get {
return formBorderStyle;
} set {
formBorderStyle = value;
if(EnableSkin) {
base.FormBorderStyle = FormBorderStyle.None;
} else {
base.FormBorderStyle = formBorderStyle;
}
}
}
internal MyForm() {
EnableSkin = false;
FormBorderStyle = FormBorderStyle.Sizable;
}
}
And the problem I'm having is something like this: http://blogs.msdn.com/calvin_hsia/archive/2007/05/01/windows-vista-aero-borderstyle-paint-problem-as-non-administrator.aspx
In my case, that happens when you set the EnableSkin to True, change it back to False and then, changing the FormBorderStyle will cause the issue you can see on the link above. As stated in the article, the problem doesn't happen when running VS as administrator.
That's why I'm looking for a way to refresh the VS IDE designer. In other words, now that I've found that article, I need to recreate the window just like it happens when the solution is rebuilt.