Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / August 2004

Tip: Looking for answers? Try searching our database.

Hide a default property

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrea Moro - 03 Aug 2004 13:59 GMT
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.

Signature

Thanks in advance
Andrea

?zden Irmak - 04 Aug 2004 00:18 GMT
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

> 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.
Andrea Moro - 04 Aug 2004 08:10 GMT
?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 Irmak - 04 Aug 2004 19:39 GMT
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

> ?zden,
>
[quoted text clipped - 9 lines]
>
> Andrea
Andrea Moro - 04 Aug 2004 20:44 GMT
?zden

could you make me an example? I'm finding some difficulties
to implement it.

Thanks
Andrea
?zden Irmak - 05 Aug 2004 11:22 GMT
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

> ?zden
>
[quoted text clipped - 3 lines]
> Thanks
> Andrea
Andrea Moro - 05 Aug 2004 14:05 GMT
?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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.