|
1 | 1 | <!-- default badges list --> |
2 | | - |
3 | 2 | [](https://supportcenter.devexpress.com/ticket/details/E774) |
4 | 3 | [](https://docs.devexpress.com/GeneralInformation/403183) |
5 | 4 | [](#does-this-example-address-your-development-requirementsobjectives) |
6 | 5 | <!-- default badges end --> |
7 | | -<!-- default file list --> |
8 | | -*Files to look at*: |
9 | 6 |
|
10 | | -* [Model.xafml](CS/EFCore/LookUpButtonEF/LookUpButtonEF.Win/Model.xafml) |
11 | | -* [MyLookupPropertyEditor.cs](CS/EFCore/LookUpButtonEF/LookUpButtonEF.Win/Editors/MyLookupPropertyEditor.cs) |
12 | | -<!-- default file list end --> |
13 | | -# How to add a custom button into WinForms LookupPropertyEditor to edit the currently selected record |
14 | 7 |
|
| 8 | +# XAF WinForms - How to add a custom Edit button to LookupPropertyEditor |
15 | 9 |
|
16 | | -<p> |
17 | | -LookupPropertyEditor is represented in a detail view by the LookUpEdit control, which allows various customizations. You can customize it by adding a special button that invokes a detail view for the selected object or performs any other actions.<br /><br /> |
18 | | - |
| 10 | +This example creates a [LookupPropertyEditor](https://docs.devexpress.com/eXpressAppFramework/113572/business-model-design-orm/data-types-supported-by-built-in-editors/reference-foreign-key-complex-type-properties#lookuppropertyeditor-1) descendant with a custom Edit button. |
19 | 11 |  |
20 | | - |
21 | | - <br /><br /><strong>See Also:</strong></p> |
22 | | -<p><a href="https://www.devexpress.com/Support/Center/p/e1101">How to work with referenced properties via a simple drop down list instead of the standard LookupPropertyEditor (Example)</a></p> |
23 | 12 |
|
24 | | -<br/> |
| 13 | +## Implementation Details |
25 | 14 |
|
| 15 | +Follow the steps below to add a custom button to LookupPropertyEditor: |
| 16 | + |
| 17 | +1. Create a [LookupPropertyEditor](https://docs.devexpress.com/eXpressAppFramework/113572/business-model-design-orm/data-types-supported-by-built-in-editors/reference-foreign-key-complex-type-properties#lookuppropertyeditor-1) descendant ([MyLookupPropertyEditor.cs](CS/EFCore/LookUpButtonEF/LookUpButtonEF.Win/Editors/MyLookupPropertyEditor.cs)). |
| 18 | + |
| 19 | +2. Access the [RepositoryItemLookupEdit](https://docs.devexpress.com/WindowsForms/DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit) and use its settings to customize LookupPropertyEditor: |
| 20 | + * Add a custom button to the [Buttons](https://docs.devexpress.com/WindowsForms/DevExpress.XtraEditors.Repository.RepositoryItemButtonEdit.Buttons) collection. |
| 21 | + * Subscribe to the [ButtonClick](https://docs.devexpress.com/WindowsForms/DevExpress.XtraEditors.Repository.RepositoryItemButtonEdit.ButtonClick) event and implement custom logic in the event handler. |
| 22 | +3. Assign the LookupPropertyEditor descendant to a business object's PropertyEditorType in the Model Editor ([Model.xafml](CS/EFCore/LookUpButtonEF/LookUpButtonEF.Win/Model.xafml)). |
| 23 | + |
| 24 | +## Files to Review |
| 25 | + |
| 26 | +- [Model.xafml](CS/EFCore/LookUpButtonEF/LookUpButtonEF.Win/Model.xafml) |
| 27 | +- [MyLookupPropertyEditor.cs](CS/EFCore/LookUpButtonEF/LookUpButtonEF.Win/Editors/MyLookupPropertyEditor.cs) |
| 28 | + |
| 29 | +## Documentation |
| 30 | + |
| 31 | +- [Customize a Built-in Property Editor (WinForms)](https://docs.devexpress.com/eXpressAppFramework/113104/ui-construction/view-items-and-property-editors/property-editors/customize-a-built-in-property-editor-winforms) |
26 | 32 |
|
27 | 33 | <!-- feedback --> |
28 | 34 | ## Does this example address your development requirements/objectives? |
29 | 35 |
|
30 | | -[<img src="https://www.devexpress.com/support/examples/i/yes-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=XAF_how-to-add-a-custom-button-into-lookuppropertyeditor-to-edit-the-currently-selected-record-e774&~~~was_helpful=yes) [<img src="https://www.devexpress.com/support/examples/i/no-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=XAF_how-to-add-a-custom-button-into-lookuppropertyeditor-to-edit-the-currently-selected-record-e774&~~~was_helpful=no) |
| 36 | +[<img src="https://www.devexpress.com/support/examples/i/yes-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=xaf-win-custom-button-in-lookup-property-editor&~~~was_helpful=yes) [<img src="https://www.devexpress.com/support/examples/i/no-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=xaf-win-custom-button-in-lookup-property-editor&~~~was_helpful=no) |
31 | 37 |
|
32 | 38 | (you will be redirected to DevExpress.com to submit your response) |
33 | 39 | <!-- feedback end --> |
0 commit comments