I have a CollectionEditor that is displayed for a ColumnHeader, and I want to limit which properties show up. The good news, I have it working but it uses a CustomTypeDescriptor and I don't like it. It tends to cause issues for me because I'm serializing the control using XAML and I can't have the ICustomTypeDescriptor filtering things during the serialization. I've gotten around this by setting a global flag and checking it, but it's really ugly code IMO. Anyhow, for every other control I have been able to use the DesignerAttribute w/ a ControlDesigner and overriden the PreFilterProperties subroutine. So I was originally thinking I could do the same: | <Designer(GetType(MyColumnHeaderDesigner))>_ | | PublicClassMyColumnHeader | | InheritsSystem.Windows.Forms.ColumnHeader | | ... | | EndClass | | | FriendClassMyColumnHeaderDesigner | | InheritsSystem.Windows.Forms.Design.ControlDesigner | | ... | | ProtectedOverridesSubPreFilterProperties(ByValpropertiesAsSystem.Collections.IDictionary) | | ... | | EndSub | | EndClass |
But then I realized that the ColumnHeader isn't a control, so this wouldn't be valid. So now I'm trying to figure out if there's any other way to filter the properties that appear in directly on the CollectionEditor itself. ie: | PublicClassMyControl | | ... | | <Editor(GetType(MyCollectionEditor),GetType(Drawing.Design.UITypeEditor))>_ | | PublicReadOnlyPropertyColumns()AsListView.ColumnHeaderCollection | | ... | | EndProperty | | ... | | EndClass | | | FriendClassMyCollectionEditor | | InheritsCollectionEditor | | ... | | EndClass |
Thanks for any help. - Edited byFBNitro Friday, March 27, 2009 9:47 PMtypo
-
| | FBNitro Friday, March 27, 2009 6:07 PM | Hi FBNitro, I know that you don't like extending CustomTypeDescriptor or implement ICustomTypeDescriptor. However, based on my experience, I can't find an elegant way to do the filtering other than this. Does set the BrowsableAttribute to false work? Best regards, Bruce Zhou Please mark the replies as answers if they help and unmark if they don't.- Marked As Answer byFBNitro Wednesday, April 01, 2009 3:27 PM
-
| | Bruce.Zhou Wednesday, April 01, 2009 8:34 AM | Hi FBNitro, I know that you don't like extending CustomTypeDescriptor or implement ICustomTypeDescriptor. However, based on my experience, I can't find an elegant way to do the filtering other than this. Does set the BrowsableAttribute to false work? Best regards, Bruce Zhou Please mark the replies as answers if they help and unmark if they don't.- Marked As Answer byFBNitro Wednesday, April 01, 2009 3:27 PM
-
| | Bruce.Zhou Wednesday, April 01, 2009 8:34 AM | Unfortunately, the BrowsableAttribute doesn't do everything I need it to. I have to change properties from being Read/Write to Read only based on some Meta Data, but only for the Property Box display. The actual property has to remain R/W so we can still access it through the code and ensure it gets serialized. What I have is working. The only downside is that before I XAML serialize I have to set a flag to indicate that I'm serializing so it doesn't filter things out at that time. A few days ago, one of the other developers came along and was doing stuff, forgot to set the flag and everything went downhill from there. After that occurred, I've been trying to find alternate ways to do it to avoid that sort of scenario from reappearing but I keep hitting different problems. Anyhow, thanks for the response, it firms up that what I did the first time seems to have been my only option. I'll ignore the ugly code for the time being. | | FBNitro Wednesday, April 01, 2009 3:25 PM | You are welcome. Glad to help. Best regards, Bruce Zhou Please mark the replies as answers if they help and unmark if they don't. | | Bruce.Zhou Thursday, April 02, 2009 2:50 AM | Are you attempting filter your properties using the solution available here? http://social.msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/80297116-f59e-452d-80ca-687f1c5429f2 Do you mark your members and properties that want ignore in the serialization process using NonSerialized and XMLIgnore attributes? [NonSerialized], private SomeUnFriendlyType myType: [System.Xml.Serialization.XmlIgnore] public SomeUnFriendlyType MyType() .... | | Tabas Thursday, April 02, 2009 4:40 AM | No I am not using that code. It's not useful in my scenario, thanks for trying though. | | FBNitro Thursday, April 02, 2009 4:42 PM |
|