This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
When editing a custom collection, it appears that you must implement IList (not just IList Unfortunately, it doesn't appear to handled fixed sized lists correctly. If you have an IList implementation where IsFixedSize returns true, the add/remove buttons shouldn't be available. However, right now they are. You can easily work around the Add button's functionality by having IList.Add return -1, but there is no way to handle RemoveAt. The proper way to handle it is to raise NotSupportedException, but this doesn't get handled within the property grid, and will bubble up/tear down the application. Ideally, when IList.IsFixedSize is true, the collection shouldn't even show the options for adding/removing. -Reed |
|
|
More information - I can work around this internally by having Remove just do nothing - it seems to work if I don't follow the docs and have it raise exceptions - and just have it be a null operation when IsFixedSize == true, but this isn't ideal, as it still shows the icons and makes the class violate normal expectations for IList. -Reed |
|
|
Hello Reed The PropertyGrid will respect the IList.IsFixedSize property in the next nightly build, so you can remove those implementation work arounds. As for needing to implement a particular type of IList, I assume you were referring to a generic collection but it looks like the forum may have striped the angle brackets from your first post, so I'm not sure which one you're having trouble with. If this is a problem, please let me know and clarify which type of collection you want to implement. Jason Fauchelle |
|
|
You're right about the angle brackets - it was a IList(Of Bool) [VB syntax] in this case. We're implementing a series of custom collection classes, however, so it won't be just this. We need our own class for collections of various types, and was trying to figure out how to implement - it looks like the non-generic IList is required, though. When I just implemented List(Of Bool), I'd get the class editor showing "Count" and other properties instead of a "collection" of bool values. Thanks for fixing the IsFixedSize issue - will the add/remove options still be in the editor and just non-functional, or will those be removed as well? Thanks, Reed |
|
|
Hello Reed The PropertyGrid will have support for collections that extend generic IList in the next nightly build. To answer your second question, if IsFixedSize is true, the add and remove buttons will not be displayed at all. Jason Fauchelle |
|