April 25th, 2012, 07:58 PM
runtime DesignSurface controls quirk
I am using the DesignSurface (ds) at runtime to allow end user to move and re-size controls.
I want the user to be able to pre-view the form in another tab, the "Preview" tab. When user selects the preview tab, if you simply change the parent or copy all the controls from the "Design" tab into the "Preview" tab, the Preview tab acts just like the DesignSurface. It's as if there are some hidden control properties for each of the controls that port right over into the Preview tab.
Is there a quick way to just dump all the ds controls into the preview tab without turning the preview tab into a designsurface?
FYI, if you do the reverse (move controls from preview tab to design tab), it kills the designsurface functionality in the design tab. There must definitely be some hidden properties directing the designsurface behavior for each control.
April 27th, 2012, 11:18 PM
Re: runtime DesignSurface controls quirk
Apparently, it's probably not a "quirk." After exhaustive researching, I finally found that it appears that whether or not a control is in designer mode can be tested through the control.site.designmode property.
This is, unfortunately, a read only property. ****, I wish it was settable! ;-(
I tried the following, in which I would attempt to exclude the control.site.designmode property from being copied into my new control:
Next step would be to exclude the site.designmode property, except that this code does not even make the control displayable when it is added. The newcontrol is definitely added, but something is wrong, and it will not display.
CheckedListBox newControl = new CheckedListBox();
var oldControlProperties = oldControlType.GetProperties();
foreach (PropertyInfo property in oldControlProperties)
var oldControlPropertyValue = property.GetValue(oldControl, null);
if (property.CanWrite && !property.Name.ToUpper().Contains("PARENT"))
if (oldControlPropertyValue != property.GetValue(newControl, null))
property.SetValue(newControl, oldControlPropertyValue, null);
Anybody have any idea on how to copy all settable properties into newcontrol from oldcontrol, except for the parent and desigmode?
Or if not, can anyone spot why my newcontrol is failing to display?
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.