ComboBoxPropertyEditor problems

Grids for WPF Forum

Posted 15 years ago by Aliaksei
Avatar
Hi,
I try to use propertygrid with combobox and I have some problem.
I can't find any examples of combo editor usage.
I have entity Employee which have property EmployeeTypeId. I would like to use combobox editor which filled by EmployeeType entities (EmployeeTypeId, EmployeeTypeDescription, ...). Selected in combobox employee type must be saved in EmployeeTypeId property of Employee entity. But I can't find how I can set SelectedValuePath/DisplayMemberPath for combo editor. How I can solve this problem?

Thank you.

Comments (2)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Aliaksei,

This depends largely on your setup, but the default editor will use a ComboBox when there are "standard values". In your case, the standard values from the EmployeeTypeId property would be a list of EmployeeType instances. Now, the problem with this is that the type of the property needs to match the type of the standard values. Which I'm guessing are not the same, since EmployeeTypeId is probably an integer or Guid.

What you would probably need to do is use a custom property editor for the EmployeeTypeId property. The "PropertyGrid Integration (Custom)" Demo under our Editors product shows how this can be done, as well as the "Property Editors" QuickStart under the PropertyGrid section. You would just use a ComboBox whose ItemsSource, SelectedValuePath, and DisplayMemberPath are set to your list. You would also need to bind the SelectedValue property to the IPropertyDataAccessor.Value (see the samples for how to do this).

Hope this helps.


Actipro Software Support

Posted 15 years ago by Aliaksei
Avatar
Hi,
Many thanks. It's help me.
The latest build of this product (v24.1.2) was released 7 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.