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
|
Hello, I have included a repro project. I'm binding an object to the propertygrid which has two integer properties (i.e. SimpleInt and ListInt). The ListInt has a TypeConverter attribute which implements the GetStandardValues. If I bind the object to the PropertyGrid the ListInt property has a dropdown as it should be. The SimpleInt has a default editor which is a textbox. However throughout the application I would like to use a specific editor (which has more functionality) for the "int" except for when it has a TypeConverter (i.e. [TypeConverter(typeof(ListIntConverter))]) which implements GetStandardValues. For integer properties with the TypeConverter I would like to still use the combobox. The second propertygrid is a control derived from the Mindscape propertygrid (similar to how we are doing in our application but left out several details). I tried to define an editor for integer but then it overrides the combobox editor for the integers with the TypeConverter. I'm trying to avoid going to each specific use of the propertygrid and specifying detail editors in each place. In the repro project I would like to use the Mindscape editor IntegerTextBox when a simple integer property is defined and the dropdown list when the TypeConverter is specified as an attribute for the integer. Also it seems that for integers (and doubles) the EditorKey in BuiltInEditorStyleCollection is PropertyGrid.SimpleTextEditorKey instead of PropertyGrid.IntegerEditorKey (or PropertyGrid.DoubleEditorKey). Thanks Oscar |
|
|
Hi Oscar, Thanks for the repro. This is an interesting scenario which I have not come across before. We do not plan to include this feature, but you should be able to do something at your end. Try creating a class that extends the TypeEditor class, and override the CanEdit method. From the node, you should be able to check the Property.Converter property to determine if this is one of your simple or list integers. Combine this result with a call to the base implementation of CanEdit that checks the type. Then of course you can use an instance of this custom TypeEditor in your default property grid editors. Note that I have not tried this before, so let me know if you have questions about any of this. As for the built in editors, the integer and double keys were added for the DataGrid - which also uses these keys. The PropertyGrid probably should have always had such keys and used them. Unfortunately this kind of change can only be done in a major version update due to breaking changes, but this was never done. I hope it does not cause trouble for you. -Jason Fauchelle |
|
|
Hi Jason, Thanks for you response. I found a possible solution where I changed the EditorTemplate for the integer to use a contentcontrol with DataTriggers which checks if StandardValues are supported or not (this is done in converters which use the nodes Property.Converter property). Based on this I then select the content of the contentcontrol to be the textbox type editor or the combobox. The DataTemplate looks something like this:
I am curious about your approach and will give it a try to see how it works. Thanks Oscar |
|