Note that there are some explanatory texts on larger screens.

plurals
  1. PODesign Surface override enabled property of a control
    text
    copied!<p>I have a little application that implements a DesignSurface as well as a propertyGrid. The propertygrid watches for a property attribute "IdeAccessable". For each property to become availdable I override the base property and add this attribute.</p> <p><Code> public class MyButton : Button {<br /> &nbsp;&nbsp;[IdeAccessable()]<br /> &nbsp;&nbsp;public new int Height { get { retun base.Height; } set { base.Height = value } }<br /><br /> &nbsp;&nbsp;[IdeAccessable()]<br /> &nbsp;&nbsp;public new int Width { get { retun base.Width ; } set { base.Width = value } }<br /><br /> &nbsp;&nbsp;[IdeAccessable()]<br /> &nbsp;&nbsp;public new bool Enabled { get { retun base.Enabled ; } set { base.Enabled = value }}<br /><br /> &nbsp;&nbsp;[IdeAccessable()]<br /> &nbsp;&nbsp;public new bool Visible { get { retun base.Visible ; } set { base.Visible = value }<br /><br /> } </Code></p> <p>This works fine for all, but for Enabled and Visible. These two property seem not to be delegated during the "Design Time" and have no effect what so ever. During serilization the keep their default / base value. How to override enabled &amp; visible that the work at design time / are delegated properly?</p> <p>Details:</p> <p>The <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.design.designsurface.aspx" rel="nofollow">DesignSurface</a> is used in a standalone application written in c#. The designsurface is attached to a standard WinForm which is the base-design-surface. Items are placed by the user via the <a href="http://msdn.microsoft.com/en-us/library/system.drawing.design.itoolboxservice.aspx" rel="nofollow">ToolBoxService</a>. The Controls are mostly default winform-controls like buttons, labels etc. To control the amount of visible items which are shown via a PropertyEditor attached to the DesignSurface-Services, all controls have been derived (see example) to flag the properties with the custom IdeAccessableAttribute.</p> <p>When these layouts are serialized during save or execution, all controls &amp; components are represented in a script language (lua). During this serilizaion process (essentailly a loop over all children lying on the form) every control is touched and every property flagges with the IdeAccessable attribute is saved. During debugging I found that, as explained, that values like enabled and visible are not beeing set despite the property editor shows the correct value. This results that a component disabled during designtime is enabled during my own runtime. Another effect is that the property editor settings for the visible property allways is false. Changing it in the property editor shows the correct value but is never applied to the real value.</p> <p>A possible solution might be:</p> <p>to prevented this with a fake design time value that is transported manually.</p> <p>The problem with this solution:</p> <p>Due to the controls not having a shared base class the parts in question would have to be rewritten for every derived control individually which would result in a lot of redundant code. Not derived controls aren't anymore possible. Any change to the logic would mean that it has to be changed in about 50 classes. Also implementing new controls would result in much more work than nessary. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload