Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

RepositoryItemSearchLookUpEdit.AddNewValue Event

Fires when the “Add New” button is clicked, and allows you to add new records to the dropdown data source.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraGrid.v24.2.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

#Declaration

public event AddNewValueEventHandler AddNewValue

#Event Data

The AddNewValue event's data class is DevExpress.XtraEditors.Controls.AddNewValueEventArgs.

#Remarks

You can display the “Add New” button in the editor’s dropdown by setting the RepositoryItemSearchLookUpEdit.ShowAddNewButton property to true.

SearchLookUpEdit

Handle the AddNewValue event, which fires on clicking this button, to add a new record to the underlying data source (RepositoryItemLookUpEditBase.DataSource). After a record is created, set the e.Cancel parameter to false and assign the key value of the new record to the e.NewValue parameter. In this instance, the SearchLookUpEdit control will locate the new record and select it as the current record. This is accomplished by assigning the key value (a value of the RepositoryItemLookUpEditBase.ValueMember field) to the editor’s BaseEdit.EditValue property.

If you do not create a new record while handling the AddNewValue event, or if you do not need the SearchLookUpEdit control to locate the new record, set the e.Cancel parameter to true.

See Also