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

PopupContainerEdit Class

The editor that allows you to display any controls within its popup window.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v18.2.dll

Declaration

[DefaultBindingPropertyEx("EditValue")]
[ToolboxBitmap(typeof(ToolboxIconsRootNS), "PopupContainerEdit")]
public class PopupContainerEdit :
    PopupBaseEdit

The following members return PopupContainerEdit objects:

Remarks

You can use the PopupContainerEdit control to implement a dropdown editor displaying custom controls within its popup window. The image below shows a sample PopupContainerEdit editor with several editors and buttons displayed in the popup window:

PopupEdit

By default, the PopupContainerEdit control doesn’t provide any dropdown panel, and so clicking its dropdown button does nothing. To create a dropdown panel displaying custom controls, do the following:

  1. Create a PopupContainerControl panel, which will serve as a container for custom controls.
  2. Add any custom controls to the created panel.
  3. Bind the panel to the PopupContainerEdit control via its PopupContainerEdit.Properties.PopupControl property (see the RepositoryItemPopupContainerEdit.PopupControl topic). Once assigned, the panel is not visible on the form at runtime and is only displayed as the bound editor’s popup window.

Typically, when an end-user modifies the state of custom controls within the dropdown (for instance, modifies their text), you need to update the PopupContainerEdit editor’s edit value and/or display text. Two events are provided for this purpose: PopupContainerEdit.QueryResultValue (RepositoryItemPopupContainerEdit.QueryResultValue) and PopupContainerEdit.QueryDisplayText (RepositoryItemPopupContainerEdit.QueryDisplayText), which fire when the popup window is about to be closed.

To update the editor’s edit value with respect to the state of controls within its popup window, handle the RepositoryItemPopupContainerEdit.QueryResultValue event. By default, the display text will be generated automatically based on the current edit value (the ToString() method is called to generate the default text representation). However, it’s possible to provide custom display text by handling the RepositoryItemPopupContainerEdit.QueryDisplayText event.

In specific cases, you may need to initialize controls within the editor’s popup window (depending on the current edit value). To initialize the controls when the popup window is about to be invoked, handle the PopupBaseEdit.QueryPopUp (or RepositoryItemPopupBase.QueryPopUp) event.

Note

When a form containing a PopupContainerControl is disposed of by calling the form’s Dispose method, the PopupContainerControl.Dispose method may not be called. This takes place when the PopupContainerControl has been opened during the form’s lifetime. To free all the resources, you need to manually call the PopupContainerControl’s Dispose method. For instance, use the following code.


void Form1_Disposed(object sender, EventArgs e) {
    if (popupContainerControl1.IsDisposed) return;
    if (popupContainerControl1.Parent != null) return;
    popupContainerControl1.Dispose();
}

See the Popup Container Editor topic for more information.

Example

The following example creates a PopupContainerEdit class instance and displays a RichTextBox control in the popup window.

First, we create and customize a RichTextBox control. Then, a PopupContainerControl object is created and this will contain the RichTextBox.

To display the PopupContainerControl in the popup window, it should be assigned to the RepositoryItemPopupContainerEdit.PopupControl property.

  RichTextBox rtb = new RichTextBox();
  rtb.Dock = DockStyle.Fill;
  PopupContainerControl popupControl = new PopupContainerControl();
  popupControl.Controls.Add(rtb);

  PopupContainerEdit editor = new PopupContainerEdit();
  editor.Properties.PopupControl = popupControl;
  Controls.Add(editor);
See Also