Hiding unwanted properties [modified]
-
I have a Control and a Form. The Form is a member of the Control. I exposed the form on the Control using a get property...
class MyWindow : Form { ....public int MyProp ....{ ........get... set... ....} } class MyControl : Control { ....public MyWindow Window ....{ ........get... set... ....} }
This of course shows up in the property Window of the Control and has all the Form properties and my properties. I however don't want to see any of the Form properties, only the Window ones. So I decided to write an interface...interface Window : IComponent { ....int MyProp ....{ ........get; set; ....} } class MyWindow : Form, Window { ... } class MyControl : Control { ....public Window Window ....{ ........get... set... ....} }
I found out the interface will not show up in the designer if it doesn't inherit from IComponent. However, even when I do this all of the Form properties are still shown. Does anyone know how to fix this? At the moment I have settled for pass-through properties on my Control. (And I don't want to override evey method add the Browsable(false) attribute to each one Thanks, Chris McGrath -- modified at 21:04 Thursday 12th April, 2007 -
I have a Control and a Form. The Form is a member of the Control. I exposed the form on the Control using a get property...
class MyWindow : Form { ....public int MyProp ....{ ........get... set... ....} } class MyControl : Control { ....public MyWindow Window ....{ ........get... set... ....} }
This of course shows up in the property Window of the Control and has all the Form properties and my properties. I however don't want to see any of the Form properties, only the Window ones. So I decided to write an interface...interface Window : IComponent { ....int MyProp ....{ ........get; set; ....} } class MyWindow : Form, Window { ... } class MyControl : Control { ....public Window Window ....{ ........get... set... ....} }
I found out the interface will not show up in the designer if it doesn't inherit from IComponent. However, even when I do this all of the Form properties are still shown. Does anyone know how to fix this? At the moment I have settled for pass-through properties on my Control. (And I don't want to override evey method add the Browsable(false) attribute to each one Thanks, Chris McGrath -- modified at 21:04 Thursday 12th April, 2007You can try to create a custom TypeConverter[^] for your window, which filters the Window properties.
[Converter(typeof(MyWindowConverter ))]
class MyWindow : Form
{
...
}or maybe:
[Converter(typeof(MyWindowConverter ))]
interface Window : IComponent
{
...
}class MyWindowConverter : TypeConverter {
override GetPropertiesSupported()
{
// indicate you want property filtering
return true;
}override GetProperties(...)
{
// return only the properties you want here
// not sure how to do this out of my head, sorry
}}
Sorry i don't have a complete answer, but i hope this gives you a start. If you don't get it working please reply so i can research further. - alwinus
-
I have a Control and a Form. The Form is a member of the Control. I exposed the form on the Control using a get property...
class MyWindow : Form { ....public int MyProp ....{ ........get... set... ....} } class MyControl : Control { ....public MyWindow Window ....{ ........get... set... ....} }
This of course shows up in the property Window of the Control and has all the Form properties and my properties. I however don't want to see any of the Form properties, only the Window ones. So I decided to write an interface...interface Window : IComponent { ....int MyProp ....{ ........get; set; ....} } class MyWindow : Form, Window { ... } class MyControl : Control { ....public Window Window ....{ ........get... set... ....} }
I found out the interface will not show up in the designer if it doesn't inherit from IComponent. However, even when I do this all of the Form properties are still shown. Does anyone know how to fix this? At the moment I have settled for pass-through properties on my Control. (And I don't want to override evey method add the Browsable(false) attribute to each one Thanks, Chris McGrath -- modified at 21:04 Thursday 12th April, 2007I think these attributes might be what you're looking for: [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] Tris Edit: Just re-read your post. Nevermind.
------------------------------- Carrier Bags - 21st Century Tumbleweed.