How to use CustomEditor with Dynamic Properties for Propertygrid
Hi,
I have been trying to use a custom editor to dynamic properties unsuccessfully. Using the example given on thread https://www.syncfusion.com/forums/147525/dynamic-properties-for-propertygrid-at-runtime as a starting point I wanted to change one of the properties value type to a List<string> then use a CustomEditor to apply a combobox with the values in the List. Unfortunately, the function "public object Create(PropertyInfo propertyInfo)" on ITypeEditor is passing in a null for propertyInfo so an editor can not be applied to the property. Here us the initialization code:
string candidateName = "John";
int age = 30;
_CanididateDetails.Values.Add("Name", candidateName);
_CanididateDetails.Values.Add("Address", new List<string>() { "A", "B" });
_CanididateDetails.Values.Add("Age", age);
this.propertyGrid.SelectedObject = _CanididateDetails;
CustomEditor comboeditor = new CustomEditor() { HasPropertyType = true, PropertyType = typeof(List<string>), Editor = new ComboEditor() };
comboeditor.Properties.Add("Address");
propertyGrid.CustomEditorCollection.Add(comboeditor);
propertyGrid.RefreshPropertygrid();
Error happens here:
I have attached an example as well.
Any help would be great!
Attachment: PropertyGrid_Example_b8f8e131.zip
SIGN IN To post a reply.
6 Replies
KP
Kanniyappan Panneer Selvam
Syncfusion Team
October 21, 2019 12:55 PM UTC
Hi Kevin Bushe,
Thanks for contacting Syncfusion support.
We were able to see the reported issue at our end and we will check and update you the further details on October 22nd , 2019.
We appreciate your patience until then.
Regards,
Kanniyappan P
KP
Kanniyappan Panneer Selvam
Syncfusion Team
October 22, 2019 01:13 PM UTC
Hi Kevin Bushe,
Sorry for the delay.
Currently we are validating the reported issue and update you the further details on October 24th, 2019.
We appreciate your patience until then.
Regards,
Kanniyappan P
KP
Kanniyappan Panneer Selvam
Syncfusion Team
October 23, 2019 01:22 PM UTC
Hi Kevin Bushe,
Thanks for your patience.
We have checked your reported behavior and this occurred because PropertyInfo is not available for dynamic properties which class type is the ICustomTypeDescriptor . We've prepared a sample to achieve your requirement. In this sample, dynamic object values are updated using the propertyItem instead of PropertyInfo. We plan to provide support for this type of dynamic properties in any of our upcoming release. Meanwhile, we suggest that you use the work-around to meet your requirements. Please find the sample for the same from below.
Code Snippet:
|
public void Attach(PropertyViewItem property, PropertyItem info)
{
var binding = new Binding("Value")
{
Mode = BindingMode.TwoWay,
Source = info,
ValidatesOnExceptions = true,
ValidatesOnDataErrors = true
};
BindingOperations.SetBinding(combo, ComboBox.SelectedItemProperty, binding);
dynamic list = info.Value;
foreach (dynamic v in list)
{
combo.Items.Add(v);
}
combo.SelectedIndex = 0;
} |
Screenshot:
Sample: https://www.syncfusion.com/downloads/support/forum/148447/ze/PropertyGrid_Example(1)-711581710.zip
Regards,
Kanniyappan P
KB
Kevin Bushe
October 28, 2019 04:45 PM UTC
Hi Kanniyappan,
Thank you for the outstanding support. The example you provided works great.
Regards,
Kevin
KP
Kanniyappan Panneer Selvam
Syncfusion Team
October 29, 2019 11:54 AM UTC
Hi Kevin Bushe,
Thanks for you update.
We are glad to know that the reported issue has been resolved at your end. Please let us know if you need any further assistance on this. We are happy to help you.
And currently we are validating your requirement as feature request and update you the further details on October 30th , 2019.
Regards,
Kanniyappan P
KP
Kanniyappan Panneer Selvam
Syncfusion Team
October 31, 2019 04:56 PM UTC
Hi Kevin Bushe,
Thanks for your patience.
We have logged the feature request on your requirement and it can be tracked through our feedback portal below.
Feedback Link : https://www.syncfusion.com/feedback/9847/unable-to-access-property-info-of-a-dynamic-object-when-creating-customeditor
The feature will be available in any of our upcoming releases.
Regards,
Kanniyappan P
SIGN IN To post a reply.
- 6 Replies
- 2 Participants
-
KB Kevin Bushe
- Oct 20, 2019 03:21 PM UTC
- Oct 31, 2019 04:56 PM UTC