windowsforms-devexpress-dot-xtraeditors-dot-repository-dot-repositoryitempopupbase-109d9c5f.md
Enables you to specify whether changes are saved or discarded when closing the popup window.
Namespace : DevExpress.XtraEditors.Repository
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXCategory("Events")]
public virtual event CloseUpEventHandler CloseUp
<DXCategory("Events")>
Public Overridable Event CloseUp As CloseUpEventHandler
The CloseUp event's data class is CloseUpEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| AcceptValue | Gets or sets a value indicating whether CloseUpEventArgs.Value should be accepted or discarded. |
| CloseMode | Gets a value indicating how the popup editor’s dropdown window was closed. |
| PressedButton | Returns which popup button has been pressed by an end-user. |
| Value | Gets or sets a value to assign to the editor’s edit value. |
The CloseUp event fires when closing the popup window. The event’s parameters allow you to change the value the user submitted and to specify whether to accept or discard the value.
Initially, the CloseUpEventArgs.AcceptValue parameter indicates whether the modifications performed within the popup window are about to be saved or discarded. The parameter’s initial value is false in the following cases:
When closing the popup window using other methods, the CloseUpEventArgs.AcceptValue parameter value is initially true , and modifications are about to be accepted. If you need to override the default behavior, change the parameter value. If you need to modify the value before it is accepted, modify the CloseUpEventArgs.Value parameter.
Note: you can also handle the RepositoryItem.EditValueChanging event to control the values to be accepted by the editor.
The editor’s PopupBaseEdit.CloseUp event is equivalent to the current event.
Note
When using popup editors within bars, do not invoke modal windows while handling the CloseUp event. Opening modal windows will cause data loss.
The following example shows how you can restrict user input in a date editor. The user is able to enter dates between January 1 and December 31 of the current year. Other dates are not acceptable. If the user selects a date less than January 1, the edit value will be set to January 1. If the selected date is greater than December 31, the edit value will be set to the maximum possible date.
For this purpose, we will use the editor’s PopupBaseEdit.CloseUp event. Its handler is listed below.
Note that the user can enter the date in the edit box without activating the dropdown window. In this case, the PopupBaseEdit.CloseUp event is not fired, and therefore, no validation is performed. To prevent such situations, you can set the RepositoryItemButtonEdit.TextEditStyle property to TextEditStyles.DisableTextEditor. Another method is to handle the RepositoryItem.EditValueChanging event, to control edit value changes.
using DevExpress.XtraEditors.Controls;
private void dateEdit1_CloseUp(object sender, CloseUpEventArgs e) {
DateTime selectedDate = (DateTime)e.Value;
int currentYear = DateTime.Today.Year;
if (selectedDate.Year < currentYear)
e.Value = new DateTime(currentYear, 1, 1);
else
if (selectedDate.Year > currentYear)
e.Value = new DateTime(currentYear, 12, 31);
}
Private Sub DateEdit1_CloseUp(ByVal sender As Object, _
ByVal e As DevExpress.XtraEditors.Controls.CloseUpEventArgs) _
Handles DateEdit1.CloseUp
Dim selectedDate As DateTime = CType(e.Value, DateTime)
Dim currentYear As Integer = DateTime.Today.Year
If selectedDate.Year < currentYear Then
e.Value = New DateTime(currentYear, 1, 1)
ElseIf (selectedDate.Year > currentYear) Then
e.Value = New DateTime(currentYear, 12, 31)
End If
End Sub
The following code snippets (auto-collected from DevExpress Examples) contain references to the CloseUp event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-grid-use-layoutview-as-master-view/CS/WindowsApplication3/MasterDetailHelper.cs#L102
item.QueryPopUp += OnPopup;
item.CloseUp += OnCloseUp;
view.GridControl.RepositoryItems.Add(item);
winforms-imagecomboboxedit-disable-specific-items/CS/WindowsApplication33/Form1.cs#L34
imageComboBoxEdit1.Properties.DrawItem += new DevExpress.XtraEditors.ListBoxDrawItemEventHandler(Properties_DrawItem);
imageComboBoxEdit1.Properties.CloseUp += new CloseUpEventHandler(Properties_CloseUp);
imageComboBoxEdit1.Properties.QueryCloseUp += new CancelEventHandler(Properties_QueryCloseUp);
winforms-grid-use-layoutview-as-master-view/VB/WindowsApplication3/MasterDetailHelper.vb#L113
AddHandler item.QueryPopUp, AddressOf OnPopup
AddHandler item.CloseUp, AddressOf OnCloseUp
view.GridControl.RepositoryItems.Add(item)
winforms-imagecomboboxedit-disable-specific-items/VB/WindowsApplication33/Form1.vb#L30
AddHandler imageComboBoxEdit1.Properties.DrawItem, New ListBoxDrawItemEventHandler(AddressOf Properties_DrawItem)
AddHandler imageComboBoxEdit1.Properties.CloseUp, New CloseUpEventHandler(AddressOf Properties_CloseUp)
AddHandler imageComboBoxEdit1.Properties.QueryCloseUp, New CancelEventHandler(AddressOf Properties_QueryCloseUp)
See Also