|
Hi, How can one show a UITypeEditor for a property that does not have a set ? To give you an example the CollectionEditor is shown for properties of type List<T> even if they do not have a set. How is that achievable for other properties ? Regards, Rajeev
- Moved bynobugzMVP, ModeratorTuesday, April 28, 2009 2:39 PMdesigner q (From:Windows Forms General)
-
|
| rajeev511 Friday, April 24, 2009 7:45 AM |
I've noticed that, however it works fine when I try it. Clicking the little button with three dots in the propertyGrid next to the "Array" property invokes the EditValue method of MyUITypeEditor, isn't that what you wanted?
class Test
{
private ABC[] array = new ABC[] { new ABC(), new ABC() };
[Editor(typeof(MyUITypeEditor), typeof(UITypeEditor))]
public ICollection Array
{
get
{
return array;
}
}
}
Let me know if I'm missing anything. /Calle
- Still confused, but on a higher level - - Marked As Answer byrajeev511 Tuesday, May 12, 2009 10:56 AM
-
|
| Calle Mellergardh Monday, May 11, 2009 10:58 AM |
Hi Calle, You are right. It works when the property's return type is ICollection. This seems to be the best solution so far if we accept the following drawbacks: 1) It would be painful to typecast the property to the appropriate array before using it every time 2) There is no chance of having a DropDown editor I was expecting a more simple solution like an attribute or something in the TypeConverter or the UITypeEditor. But looks like there isn't one. Thanks once again ! Regards, Rajeev - Marked As Answer byrajeev511 Tuesday, May 12, 2009 10:56 AM
-
|
| rajeev511 Tuesday, May 12, 2009 10:56 AM |
A List<> is different, editing doesn't change the List instance, it changes the list elements. There's no point in writing an editor for regular properties that don't have a setter, you can't change the value.
Hans Passant. |
| nobugz Friday, April 24, 2009 1:50 PM |
Hi, That is not true. I could have a property without a set that is an array of a type which has a changeable Boolean variable. Like the one below
class ABC
{
private bool enabled;
public bool Enabled
{
get{return enabled;}
set{enabled = value;}
}
}
In the above case I would want to have a UITypeEditor that simply lets me change the property Enabled. I dont need to change the array altogether but only do something to the elements. I hope you understood that. Regards, Rajeev |
| rajeev511 Friday, April 24, 2009 3:01 PM |
Well, an array is just another collection object. Same rules apply, you want to edit the elements, not the array instance. Do you have a specific question about this? Hans Passant. |
| nobugz Friday, April 24, 2009 3:05 PM |
Here is the scenario. If you try the below given code you will notice that the property Array is shown as if a UITypeEditor cannot be shown from it (unlike a List<ABC> which would have shown a standard CollectionEditor)
class Test
{
private ABC[] array = new ABC[] { new ABC(), new ABC() };
[Editor(typeof(MyUITypeEditor), typeof(UITypeEditor)]
public ABC[] Array
{
get { return array; }
}
}
class ABC
{
private bool enabled;
public bool Enabled
{
get { return enabled; }
set { enabled = value; }
}
}
To reiterate, what can I do so that MyUITypeEditor.EditValue is invoked for the above given scenario when i show the object of Test in a property grid ? Regards, Rajeev |
| rajeev511 Friday, April 24, 2009 3:19 PM |
Sorry for being pushy, but is it just not possible ? Could somebody please confirm whether it even has a solution or not ? Thanks, Rajeev |
| rajeev511 Tuesday, April 28, 2009 1:29 PM |
To get the behaviour you're looking for theproperty you have must return an ICollection. Also, in your custom type editor you must override the GetEditStyle method and return UITypeEditorEditStyle.Modal.
/Calle
- Still confused, but on a higher level - |
| Calle Mellergardh Friday, May 08, 2009 8:57 AM |
Hi Calle, Thank you for the reply. However that does not solve the problem. Please note that there is no set in the property that I am trying to invoke the editor for, just in case you missed it. Thanks anyway. Regards, Rajeev |
| rajeev511 Monday, May 11, 2009 10:16 AM |
I've noticed that, however it works fine when I try it. Clicking the little button with three dots in the propertyGrid next to the "Array" property invokes the EditValue method of MyUITypeEditor, isn't that what you wanted?
class Test
{
private ABC[] array = new ABC[] { new ABC(), new ABC() };
[Editor(typeof(MyUITypeEditor), typeof(UITypeEditor))]
public ICollection Array
{
get
{
return array;
}
}
}
Let me know if I'm missing anything. /Calle
- Still confused, but on a higher level - - Marked As Answer byrajeev511 Tuesday, May 12, 2009 10:56 AM
-
|
| Calle Mellergardh Monday, May 11, 2009 10:58 AM |
Hi Calle, You are right. It works when the property's return type is ICollection. This seems to be the best solution so far if we accept the following drawbacks: 1) It would be painful to typecast the property to the appropriate array before using it every time 2) There is no chance of having a DropDown editor I was expecting a more simple solution like an attribute or something in the TypeConverter or the UITypeEditor. But looks like there isn't one. Thanks once again ! Regards, Rajeev - Marked As Answer byrajeev511 Tuesday, May 12, 2009 10:56 AM
-
|
| rajeev511 Tuesday, May 12, 2009 10:56 AM |