Skip to main content
A newer version of this page is available. .

How to: Prevent Popup Window Closing for PopupContainerEdit

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.

PopupBaseEdit_QueryCloseUp_example

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:

using System.ComponentModel;
private void popupContainerEdit1_QueryCloseUp(object sender, CancelEventArgs e) {
    e.Cancel = listBoxControlDest.ItemCount == 0;
}