Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

How to hide a object's inherited properties ?

I create a user control object and show its properties through a propertygrid object in my application. It is sure that there are 100 hundred of properties inherited from System.Windows.Forms.UserControl and they are all showd on the propertygrid object. Is there a way i can hide all these inherited properties and show only my user control's properties ?
0
mrvithan
Asked:
mrvithan
  • 4
  • 3
1 Solution
 
tomvergoteCommented:
uh, you could sorta shadow methods or override them, but you'll have to go through all 100 properties

look here:
http://www.developerfusion.com/show/3821/9/
0
 
mrvithanAuthor Commented:
- -'' you mean I have to do kind of

[BrowsableAttribute (False)]
public override xxxx ()
{
     base.xxx ();
}

for all of the inherited properties ?  T_T
0
 
tomvergoteCommented:
yup, as far as i know at least
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mrvithanAuthor Commented:
- -'' .... ok i think i will wait more ..... ^^''
0
 
tomvergoteCommented:
I think it's pointless, thats the purpose of inheriting from something, you inherit all its properties, unless you override them
0
 
NipNFriar_TuckCommented:
You could use a custom attribute and then in your properties page only display those properties with the custom attribute... Basically you create a class that inherits from attribute:

public class ShowMyProperty : Attribute {
}

Then when everyou want to display a property in your form you would do something like:

[ShowMyProperty]
public string MyString {
   get { return myString; }
   set { myString = value; }
}

Then when you are building your properties page you get the property info...
PropertyInfo[] piArray = myClass.GetProperties();

Then go through the properties...
foreach ( PropertyInfo pi in piArray ) {
   ShowMyProperty[] smp = (ShowMyProperty[])pi.GetCustomAttributes( typeof( ShowMyProperty ) );
   if ( smp != null ) {
      // perfrom action for property to be displayed
   }
}


HTH
0
 
mrvithanAuthor Commented:
One again that i can't get the right solution for a not-in-a-book question.

To tomvergote, your solution is a way to do. but override 100 properties is not a clever way, especially when you don't know how it does.

I will post here what i think it is the best solution: http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.dotnet.framework.windowsforms&mid=05525833-418c-44e7-a2d5-f39a07743c82

However, the point is MUST give, therefore 250 point will go with your. ^^''
0
 
tomvergoteCommented:
No the points are not a must give, you can post a request for refund, check the help button on your upper right corner.
http://www.experts-exchange.com/help.jsp#hi70
I answered my question myself. What do I do?

Post a question in the Community Support topic area asking for a refund, and asking the Moderators to close the question. You'll be required to post your solution in your original question. A Moderator will post a notice of your request which will give the participants 96 hours to object to the refund. Note that if it resembles one of the suggested comments, the likelihood is that your request will not be granted, but rather, the points will be awarded to the Expert who makes the suggestion. In your Community Support request, remember to post a link to the original question.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now