windowsforms-devexpress-dot-xtraeditors-dot-popupcontainercontrol-dot-ctor-da0584ee.md
Creates an instance of the PopupContainerControl class.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
public PopupContainerControl()
Public Sub New
Use the constructor to create a popup control at runtime. A popup control is displayed in the popup window of a PopupContainerEdit control. To assign a popup control to an editor, see the RepositoryItemPopupContainerEdit.PopupControl property.
The following example creates a PopupContainerControl with a RichTextBox inside, and assigns this control to a PopupContainerEdit editor.
using DevExpress.Utils;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.ViewInfo;
using System;
using System.Data;
using System.Windows.Forms;
namespace DXApplication10 {
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
public Form1() {
InitializeComponent();
// ...
this.Load += Form1_Load;
}
private void Form1_Load(object sender, EventArgs e) {
CreatePopupEditor();
}
void CreatePopupEditor() {
RichTextBox rtb = new RichTextBox();
rtb.Dock = DockStyle.Fill;
PopupContainerControl popupControl = new PopupContainerControl();
popupControl.Controls.Add(rtb);
PopupContainerEdit editor = new PopupContainerEdit();
editor.Location = new Point(100, 30);
editor.Width = 350;
editor.Properties.PopupControl = popupControl;
Controls.Add(editor);
editor.Closed += (s, a) => {
(s as PopupContainerEdit).EditValue = rtb.Text;
};
editor.CustomDisplayText += (s, x) => {
if (x.Value != null)
x.DisplayText = x.Value.ToString().TrimStart(' ', '\r', '\n');
};
}
}
}
Imports Microsoft.VisualBasic
Imports DevExpress.Utils
Imports DevExpress.XtraEditors
Imports DevExpress.XtraEditors.ViewInfo
Imports System
Imports System.Data
Imports System.Windows.Forms
Namespace DXApplication10
Partial Public Class Form1
Inherits DevExpress.XtraEditors.XtraForm
Public Sub New()
InitializeComponent()
' ...
AddHandler Me.Load, AddressOf Form1_Load
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
CreatePopupEditor()
End Sub
Private Sub CreatePopupEditor()
Dim rtb As New RichTextBox()
rtb.Dock = DockStyle.Fill
Dim popupControl As New PopupContainerControl()
popupControl.Controls.Add(rtb)
Dim editor As New PopupContainerEdit()
editor.Location = New Point(100, 30)
editor.Width = 350
editor.Properties.PopupControl = popupControl
Controls.Add(editor)
AddHandler editor.Closed, Sub(s, a) TryCast(s, PopupContainerEdit).EditValue = rtb.Text
AddHandler editor.CustomDisplayText, Sub(s, x)
If x.Value IsNot Nothing Then
x.DisplayText = x.Value.ToString().TrimStart(" "c, ControlChars.Cr, ControlChars.Lf)
End If
End Sub
End Sub
End Class
End Namespace
See Also