windowsforms-612-controls-and-libraries-editors-and-simple-controls-popup-container-editor.md
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):
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:
PopupContainerControl. To add UI control in code, use the PopupContainerControl.Controls property.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.
Handle the QueryResultValue event to specify the e.Value event parameter to set the editor’s value.
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);
}
Private Sub popupContainerEdit1_QueryDisplayText(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.QueryDisplayTextEventArgs)
e.DisplayText = String.Format("{0} - {1} - {2}; {3}", textEdit1.Text, textEdit2.Text, textEdit3.Text, dateEdit1.DateOnly)
End Sub
The following screenshot shows the result:
PopupContainerControl.Click event to call the ClosePopup() method.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();
}
Private Sub ButtonCancel_Click(ByVal sender As Object, ByVal e As EventArgs)
popupContainerEdit1.CancelPopup()
End Sub
Private Sub ButtonOK_Click(ByVal sender As Object, ByVal e As EventArgs)
popupContainerEdit1.ClosePopup()
End Sub
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.ESC to discard edits.