dotnet windows forms designtime:
Is there a way to hide some default property of control? I'm writing my own usercontrol, and I would like to hide some of them. For e.g. the locked property or many other. -- Thanks in advance Andrea
Overriding the property with "Shadows" in VB.Net or "new" in C# should do the trick...When you override, don't forget to mark the property's browsable attribute as false... Regards, Özden [quoted text, click to view] "Andrea Moro" <moroandreaEt@tiscali.it> wrote in message news:uoF%23ymVeEHA.596@TK2MSFTNGP11.phx.gbl... > Is there a way to hide some default property of control? > I'm writing my own usercontrol, and I would like to hide > some of them. For e.g. the locked property or many other. > > -- > Thanks in advance > Andrea > >
Özden, thanks. It works fine, for all properties I tried except for the locked. It doesn't accept shadowing nor overriding. Code looks ok, and no error is reported by the framework, but at design time, also setting browsable property to false, and changing the category, locked continue to stay to design category and visbile. Do you know anything about it? Andrea
Andrea, You may also try to filter the property... Apply a custom designer to your control and override the PostFilterProperties method and remove the "Locked" property from the given properties collection... Regards, Özden [quoted text, click to view] "Andrea Moro" <moroandreaEt@tiscali.it> wrote in message news:ei9awIfeEHA.720@TK2MSFTNGP11.phx.gbl... > Özden, > > thanks. It works fine, for all properties I tried > except for the locked. It doesn't accept shadowing > nor overriding. > Code looks ok, and no error is reported by the > framework, but at design time, also setting browsable > property to false, and changing the category, > locked continue to stay to design category and visbile. > > Do you know anything about it? > > Andrea > >
Özden could you make me an example? I'm finding some difficulties to implement it. Thanks Andrea
Hi Andrea, Apply the designer class to your custom control class like : [Designer(typeof(SampleDesigner))] Here's the code of the Designer class : public class SampleDesigner : ControlDesigner { protected override void PostFilterProperties(System.Collections.IDictionary properties) { foreach(string prop in _unneededProperties) properties.Remove(prop); base.PostFilterProperties(properties); } private static readonly string[] _unneededProperties = { "Anchor", "BackColor", "CausesValidation", "Dock", "ImeMode", "Location", "Size", "TabIndex", "TabStop", "AccessibleDescription", "AccessibleName", "AccessibleRole", "AllowDrop", "Enable", "Visible", "Enabled", "Locked", "AutoScroll", "AutoScrollMargin", "AutoScrollMinSize", "DockPadding", "ContextMenu", "RightToLeft", "BackgroundImage", "Tag" }; } Hope it helps...:) Regards, Özden [quoted text, click to view] "Andrea Moro" <moroandreaEt@tiscali.it> wrote in message news:%23vyRewleEHA.2560@TK2MSFTNGP09.phx.gbl... > Özden > > could you make me an example? I'm finding some difficulties > to implement it. > > Thanks > Andrea > >
Özden, I'm using VB, but this isn't the main problem. I'm inheriting from a usercontrol, so controldesigner isn't available for me. I've the same problems, trying to overlads the OnSetComponentDefaults. It's a member of system.design.componentmodel ... I'm loosing in a glass of water ... or in a ocean ... I don't know. Andrea
Don't see what you're looking for? Try a search.
|