Loading...
Loading...
Guide for implementing Syncfusion PopupControlContainer in Windows Forms applications. Use when creating custom popup panels, attaching popups to parent controls, or configuring auto-close behavior. Covers popup lifecycle, ShowPopup/HidePopup methods, event handling (BeforePopup, Popup, CloseUp), hosting child controls in popups, auto-scroll configuration, transparent popups, and advanced scenarios like ComboBoxBase hosting within popups.
npx skill4agent add syncfusion/winforms-ui-components-skills syncfusion-winforms-popupusing Syncfusion.Windows.Forms;
public partial class Form1 : Form
{
private PopupControlContainer popupControlContainer1;
private Button button1;
private RichTextBox richTextBox1;
public Form1()
{
InitializeComponent();
// Initialize popup container
this.popupControlContainer1 = new PopupControlContainer();
// Add child control (button in this example)
this.button1 = new Button();
this.button1.Text = "Click Me";
this.button1.Location = new Point(10, 10);
this.popupControlContainer1.Controls.Add(this.button1);
// Configure popup
this.popupControlContainer1.Size = new Size(200, 100);
// Create parent control
this.richTextBox1 = new RichTextBox();
this.richTextBox1.Size = new Size(150, 50);
this.richTextBox1.Location = new Point(20, 20);
this.richTextBox1.Click += RichTextBox1_Click;
// Associate popup with parent
this.popupControlContainer1.ParentControl = this.richTextBox1;
// Add controls to form
this.Controls.Add(this.richTextBox1);
}
private void RichTextBox1_Click(object sender, EventArgs e)
{
// Show popup at default position
this.popupControlContainer1.ShowPopup(Point.Empty);
}
}// Show at specific screen coordinates
this.popupControlContainer1.ShowPopup(new Point(100, 200));
// Show below parent control
Point location = this.richTextBox1.PointToScreen(
new Point(0, this.richTextBox1.Height));
this.popupControlContainer1.ShowPopup(location);// Simple hide
this.popupControlContainer1.HidePopup();
// Hide with close type
this.popupControlContainer1.HidePopup(PopupCloseType.Done);
this.popupControlContainer1.HidePopup(PopupCloseType.Canceled);// Prevent auto-close on outside clicks
this.popupControlContainer1.IgnoreMouseMessages = true;
// Close only when condition is met
private void ValidateButton_Click(object sender, EventArgs e)
{
if (ValidateInput())
{
this.popupControlContainer1.HidePopup(PopupCloseType.Done);
}
}private void PopupControlContainer1_CloseUp(object sender, PopupClosedEventArgs e)
{
if (e.PopupCloseType == PopupCloseType.Done)
{
// Transfer data from popup to parent form
this.textBox1.Text = this.popupTextBox.Text;
}
else if (e.PopupCloseType == PopupCloseType.Canceled)
{
// Discard changes
}
}private void PopupControlContainer1_BeforePopup(object sender, CancelEventArgs e)
{
// Make popup resizable
this.popupControlContainer1.PopupHost.FormBorderStyle = FormBorderStyle.SizableToolWindow;
this.popupControlContainer1.Dock = DockStyle.Fill;
// Set minimum size
if (this.popupControlContainer1.PopupHost.Size.Width < 200)
{
this.popupControlContainer1.PopupHost.Size = new Size(200, 150);
}
}private void PopupControlContainer1_BeforePopup(object sender, CancelEventArgs e)
{
// Set opacity for transparency
this.popupControlContainer1.PopupHost.Opacity = 0.75;
}| Property | Type | Description |
|---|---|---|
| ParentControl | Control | The control to which the popup is associated |
| IgnoreMouseMessages | bool | Prevents auto-close on outside clicks when true |
| IgnoreDialogKey | bool | Disables default keyboard closing behavior when true |
| AutoScroll | bool | Enables automatic scrollbars when content overflows |
| AutoScrollMargin | Size | Margin around scroll region |
| AutoScrollMinSize | Size | Minimum size for scroll region |
| PopupHost | Form | The host form containing the popup (access in events) |
| Method | Description |
|---|---|
| ShowPopup(Point) | Displays the popup at the specified screen coordinates |
| HidePopup() | Hides the popup |
| HidePopup(PopupCloseType) | Hides the popup with a specific close type |
| IsShowing() | Returns true if the popup is currently visible |
| Event | When Raised | Key Use Cases |
|---|---|---|
| BeforePopup | Before popup is shown | Resize popup, customize appearance, cancel showing |
| Popup | After popup is shown | Set focus, enable mnemonics |
| CloseUp | When popup is closed | Transfer data, restore focus, handle close types |
IgnoreMouseMessages = trueIgnoreDialogKeyHidePopup()Popupthis.popupControlContainer1.Focus()PointToScreen()AutoScroll = trueAutoScrollMinSizeBeforePopupOnPopup()DropDown