Skip to main content

PopupContainerControl Class

The dropdown panel for the PopupContainerEdit editor.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public class PopupContainerControl :
    PanelControl,
    ISupportLookAndFeel

The following members return PopupContainerControl objects:

Remarks

PopupContainerEdit and PopupContainerControl controls allow you to create popups/dropdowns with custom layout and use them within look-up editors and data editors with popups (dropdowns):

PopupEdit

Run Demo: Popup Container Edit

The PopupContainerControl is a panel/container that displays various UI controls and is used as the dropdown in the PopupContainerEdit control. Do the following to use it:

  1. Drop UI controls onto the PopupContainerControl. To add UI control in code, use the PopupContainerControl.Controls property.
  2. Assign the PopupContainerControl to the PopupContainerEdit.Properties.PopupControl property.

The PopupContainerEdit is a textbox-like data editor with the dropdown button. When the user clicks the dropdown button, the PopupContainerControl assigned to the editor’s PopupContainerEdit.Properties.PopupControl property is shown.

WinForms Popup Container Edit

EditValue and Display Text

Set the EditValue

Handle the QueryResultValue event to specify the e.Value event parameter to set the editor’s value.

Set the Display Text

Handle the QueryDisplayText event and set the e.DisplayText event parameter to specify the text displayed in the edit box. If you do not handle the QueryDisplayText event, the PopupContainerEdit will try to convert its EditValue into a string.

void popupContainerEdit1_QueryDisplayText(object sender, DevExpress.XtraEditors.Controls.QueryDisplayTextEventArgs e) {
    e.DisplayText = string.Format("{0} - {1} - {2}; {3}", textEdit1.Text, textEdit2.Text, textEdit3.Text, dateEdit1.DateOnly); 
}

The following screenshot shows the result:

Set the Display Text - WInForms Popup Container Edit, DevExpress

Display OK/Cancel Buttons

  1. Add OK and Cancel buttons to the PopupContainerControl.
  2. Handle the Ok button’s Click event to call the ClosePopup() method.
  3. Handle the Cancel button’s Click event to call the CancelPopup() method.
void ButtonCancel_Click(object sender, EventArgs e) {
    popupContainerEdit1.CancelPopup();
}
void ButtonOK_Click(object sender, EventArgs e) {
    popupContainerEdit1.ClosePopup();
}
  • QueryPopUp - fires when the user clicks the dropdown button. Handle the QueryPopUp event to perform specific actions before the dropdown is displayed. For example, you can prevent the dropdown from being displayed based on a specific condition. Set the e.Cancel event parameter to true to cancel the action.
  • CloseUp - fires if the user closes the popup panel or presses ESC to discard edits.

Examples (GitHub)

Inheritance

See Also