Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to 'hide' a property?
Message
From
20/09/2005 18:05:34
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01050663
Message ID:
01051476
Views:
15
Ok. Thanks. I was just showing Einar a method to accomplish what he wanted based on an example I had from a book.

I don't know if the method I showed was used because there were several properties involved and it would be easier to create the method as show and add/remove code as you decided what properties to show/hide.


>Uhm, if your goal is to override the property in the designer simply override the property and set the [Browsable(false)] attribute on the property.
>
>+++ Rick ---
>
>>Here's an example of how to remove the "text" property.
>>
>>1) Attribute clause prior to the "class" statement for your custom control:
>>
>>
>>[Designer(typeof(NumbersOnlyTextBox.NumbersOnlyTextBoxDesigner))]
>>
>>
>>2) Within your custom control class, create an internal class with the same name as after the colon above, that inherits from ControlDesigner (found in System.Windows.Forms.Design (System.Design dll).
>>
>>
>>public class NumbersOnlyTextBox.....
>>{
>>  internal class NumbersOnlyTextBoxDesigner : ControlDesigner
>>  {
>>    protected override void PostFilterProperties(
>>     System.Collections.IDictionary properties)
>>
>>     {
>>       properties.Remove("Text");
>>      }
>>  }
>>
>>}
>>
>>
>>Hope this is enough.
>>
>>>Thanks Perry.
>>>
>>>Einar
>>>>I'll do my best to remember to post a sample tonite when I'm in front of the literature I was kind of quoting from.
>>>>
>>>>PF
>>>>
>>>>>Perry,
>>>>>Wow that sounds like an awfull lot of work for such a 'simple' thing.
>>>>>Do you have an example you could post?
>>>>>
>>>>>Thanks,
>>>>>Einar
>>>>>>I don't have exactly, but I hope I can point you in the right direction.
>>>>>>
>>>>>>1) Insert a line before the line "public class....your custom control. Add a Designer attribute on this line that points to "YourClassName.DesignerClass".
>>>>>>
>>>>>>2) Add an internal class within your control class called "DesignerClass". It needs to match the name you gave in the designer attribute in #1. This class needs to inherit from ControlDesigner. This requires you to add a reference to System.Design.
>>>>>>
>>>>>>3) In the internal class you can create a override method "PostFilterProperties" with the signature:
>>>>>>protected void PostFilterProperties(System.Collections.IDictionary properties)
>>>>>>
>>>>>>4) In this new method add:
>>>>>>properties.Remove("Text");
>>>>>>
>>>>>>HTH,
>>>>>>
>>>>>>PF
>>>>>>
>>>>>>>What is the best way to 'hide' a property from the property sheet?
>>>>>>>I am creatin a custom control which I am inheriting from System.Windows.Forms.Control and as a result of that I get a Text property in the property sheet at design time. My control will not make use of the Text property so why even show it. So what is the best way of removing the Text property.
>>>>>>>
>>>>>>>Thanks,
>>>>>>>Einar

(On an infant's shirt): Already smarter than Bush
Previous
Reply
Map
View

Click here to load this message in the networking platform