This is a migrated thread and some comments may be shown as answers.

RadPropertyGrid custom dropdown editor not changing

5 Answers 199 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 27 Jul 2012, 05:45 PM
Hello,

I've got a custom editor for some PropertyGrid items that is displaying in the grid values correctly, and the subsequent drop down list is appearing correctly, however, when I select a new value, the PropertyStoreItem PropertyChanged event is not firing.

I'm using your RadPropertyGridEditorExample as a template to get started. My data source is IEnumerable<> and not List<>. That's one difference. Other than that, what insights are there what I might be missing?

Edit: I'm also using a Guid for the SelectedValue and not a more primitive type like Int32 (as per the example). Basically, otherwise, I've got the same sort of thing going on, a complex user object not unlike Digit that wraps my Domain Object and exposes value and display name sufficient to facilitate the drop down.

Thank you...

5 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 27 Jul 2012, 06:39 PM
Did a little more digging through the forums. I think I found a plausible workaround through this issue in this post: propertychange-event.
0
Michael
Top achievements
Rank 1
answered on 27 Jul 2012, 08:12 PM
OKAY! Found the answer.

In the code of our EditorInitialized event handler:

var __e_Editor_EditorElement = e.Editor.EditorElement;
__e_Editor_EditorElement.SelectedValue = ((PropertyGridItem) e.Item).Value;

Something like the Digit project example: SelectedValue.GetType() and PropertyGridItem.Value.GetType() were both Int32.

Our example was a little bit different in that the object backing the PropertyStoreItem itself was the complex object and not a primitive. So we ended up with something like typeof(Guid) != typeof(OurObject).

When I exposed a reference to the complex object this reference, this all cleared up and I got the PropertyChanged event from the PropertyStoreItem like I expect.

Hope this helps someone.



0
Ivan Petrov
Telerik team
answered on 01 Aug 2012, 08:09 AM
Hi Michael,

Thank you for writing.

There is a Type check when assigning a value to a PropertyStoreItem. The check ensures that the value coming from the editor can be assigned or converted to the type of the PropertyStoreItem. This is why the event was not firing.

I am glad you have found an answer to your question. If you have further questions, do not hesitate to write back.

Kind regards,
Ivan Petrov
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Ivajlo
Top achievements
Rank 1
answered on 28 Nov 2012, 03:55 PM
Do you know somebody how can I use
PropertyStoreItem engineFuel = new PropertyStoreItem(typeof(Fuels), "Fuel", Fuels.Petrol,
                "The type of fuel providing the energy source for the engine.", "Engine");
but instead enum type to be List<ClassName>

Thanks

0
Ivan Petrov
Telerik team
answered on 03 Dec 2012, 02:30 PM
Hello Ivajlo,

Thank you for writing.

Properties of type List<SomeClass> are edited in the property grid using the standard .NET collection editor. However if you would like to edit the list using a finite amount of predefined values you can take a look at the attached project. It uses the editor created in the following article with a few tweaks to make it work in the property grid. It allows users to use a drop down list editor and select multiple items, which are then added to the list.

I hope this will be useful. Should you have further questions, I would be glad to help.
 
Kind regards,
Ivan Petrov
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
PropertyGrid
Asked by
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Ivan Petrov
Telerik team
Ivajlo
Top achievements
Rank 1
Share this question
or