mrvithan
asked on
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.UserC ontrol 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 ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yup, as far as i know at least
ASKER
- -'' .... ok i think i will wait more ..... ^^''
I think it's pointless, thats the purpose of inheriting from something, you inherit all its properties, unless you override them
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.GetCu stomAttrib utes( typeof( ShowMyProperty ) );
if ( smp != null ) {
// perfrom action for property to be displayed
}
}
HTH
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.GetCu
if ( smp != null ) {
// perfrom action for property to be displayed
}
}
HTH
ASKER
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. ^^''
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. ^^''
No the points are not a must give, you can post a request for refund, check the help button on your upper right corner.
https://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.
https://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.
ASKER
[BrowsableAttribute (False)]
public override xxxx ()
{
base.xxx ();
}
for all of the inherited properties ? T_T