Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to implement custom WinPropertyEditor based on the ListBoxControl

$
0
0

Scenario

This example illustrates how to implement a custom WinPropertyEditor with ListBoxControl to edit reference properties in DetailView:


Steps to implement

1. Add a new class inherited from the WinPropertyEditor as shown in the Module.Win\Editors\CustomListBoxEditor.xx file.

This editor is inherited from WinPropertyEditor not to configure data bindings manually.
2. In the Model Editor, set the PropertyEditorType attribute to the custom editor type for a required reference property node, as shown in the example's Model.XAFML file.

Important notes
1. ListBoxControl
cannot correctly work with the ImmediatePostData property, because it does not contain the SelectedItemChanged event. Without this event, ListBoxControl does not send a notification to the binding mechanism when item selection is changed. This behavior was inherited from the default ListBox control. To avoid this behavior, subscribe to the ListBoxControl.SelectedIndexChanged and send notifications to the binding manually as shown in the Module.Win\Editors\CustomListBoxEditor.xx file .

2. This editor is designed to work only in DetailView.

See also:

How to: Implement a Property Editor Based on a Custom Control (Windows Forms)

Question Comments

Added By: FSuster at: 11/20/2013 1:36:34 AM    

Thanks for this usefull example. Maybe I found a bug.

This is the scenario: TestItem has a n:1 association to CategoryItem
Several CategoryItems are already saved as well as an object of the type TestItem. For this TestItem a specific CategoryItem was selected. In the TestItem's detail view the CategoryItems are displayed as a CustomListBoxEditor.

1. Open the existing detail view of the TestItem. The right value in the CustomListBoxEditor is selected.
2. Close the detail view.
3. Reopen the detail view. Now the first item of the CustomListBoxEditor is always selected, no matter what CategoryItem was saved in the TestItem.
==> The binding of "SelectedItem" only works once.

Greetings,
Stefan

Added By: Dennis (DevExpress Support) at: 2/17/2014 5:02:39 AM    

Thank you for your feedback, Stefan. We will answer you in the https://www.devexpress.com/Support/Center/Question/Details/Q571657 ticket you created.

Added By: Gilles Brice Mahabo at: 8/17/2016 1:02:06 AM    Hello guys,

I use your solution to implement  a custom WinPropertyEditor based on the ListBoxControl.
My property have a DataSourceProperty but when I use the custom WinPropertyEditor based on the ListBoxControl, it displays all the objects (of the property type) and not the objects of te DataSourceProperty.

How can I fix this please ?

Best regards,
Gilles

Added By: Alexey (DevExpress Support) at: 8/17/2016 1:05:50 AM    

Hello Gilles,

I've created a separate ticket on your behalf (T415811: E4890 with DataSourceProperty). It has been placed in our processing queue and will be answered shortly.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>