Back to Devexpress

RepositoryItemPopupBase.QueryCloseUp Event

windowsforms-devexpress-dot-xtraeditors-dot-repository-dot-repositoryitempopupbase-59f016ea.md

latest6.9 KB
Original Source

RepositoryItemPopupBase.QueryCloseUp Event

Enables you to specify whether an attempt to close the editor’s popup window will succeed.

Namespace : DevExpress.XtraEditors.Repository

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Events")]
public virtual event CancelEventHandler QueryCloseUp
vb
<DXCategory("Events")>
Public Overridable Event QueryCloseUp As CancelEventHandler

Event Data

The QueryCloseUp event's data class is CancelEventArgs. The following properties provide information specific to this event:

PropertyDescription
CancelGets or sets a value indicating whether the event should be canceled.

Remarks

The QueryCloseUp event is raised each time an attempt is made to close the editor’s popup window. Handle the event to prohibit closing the window, by setting the event’s Cancel parameter to true.

The QueryCloseUp event is raised in the following cases:

Note: QueryCloseUp is not raised when you set focus to another control, click outside of the editor’s area or switch to another application. In these cases, you can only specify whether the modifications performed within the popup window should be accepted by the editor. Handle the RepositoryItemPopupBase.CloseUp event for this purpose.

The editor’s PopupBaseEdit.QueryCloseUp event is equivalent to the current event.

Example

Consider an example of creating a PopupContainerEdit editor which displays two list box controls in the dropdown. The first list box presents all available items. The second listbox displays items chosen from the first one.

Suppose the end-user has to select items in the first list box and copy them (using, say, the ‘>>’ button) to the second list box. The popup window cannot be closed until items are copied. Such behavior is implemented using the PopupBaseEdit.QueryCloseUp event. The following code shows the QueryCloseUp event handler of the popup container editor. This allows for the closing of the popup only if the second list box contains items:

csharp
using System.ComponentModel;
private void popupContainerEdit1_QueryCloseUp(object sender, CancelEventArgs e) {
    e.Cancel = listBoxControlDest.ItemCount == 0;
}
vb
Private Sub PopupContainerEdit1_QueryCloseUp(ByVal sender As Object, _
  ByVal e As System.ComponentModel.CancelEventArgs) _
  Handles PopupContainerEdit1.QueryCloseUp
    If ListBoxControlDest.ItemCount = 0 Then
      e.Cancel = True
    End If
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the QueryCloseUp 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-imagecomboboxedit-disable-specific-items/CS/WindowsApplication33/Form1.cs#L35

csharp
imageComboBoxEdit1.Properties.CloseUp += new CloseUpEventHandler(Properties_CloseUp);
imageComboBoxEdit1.Properties.QueryCloseUp += new CancelEventHandler(Properties_QueryCloseUp);

winforms-imagecomboboxedit-disable-specific-items/VB/WindowsApplication33/Form1.vb#L31

vb
AddHandler imageComboBoxEdit1.Properties.CloseUp, New CloseUpEventHandler(AddressOf Properties_CloseUp)
AddHandler imageComboBoxEdit1.Properties.QueryCloseUp, New CancelEventHandler(AddressOf Properties_QueryCloseUp)
Dim i As ImageComboBoxItem = New ImageComboBoxItem()

See Also

QueryCloseUp

CloseUp

ClosePopup()

CancelPopup()

RepositoryItemPopupBase Class

RepositoryItemPopupBase Members

DevExpress.XtraEditors.Repository Namespace