We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to place a ComboBoxBase control within a PopupControlContainer such that the PopupControlContainer does not close when the ComboBoxBase’s popup is displayed

 

You can do this by deriving from our PopupControlContainer, overriding the OnPopup method, and setting the focus to the derived control. This ensures that the derived PopupControlContainer does not lose focus and close prematurely. The customized PopupControlContainer code should look as shown below:

[C#] public class CustomPopupControlContainer : Syncfusion.Windows.Forms.PopupControlContainer  {   public CustomPopupControlContainer()   {       }   public CustomPopupControlContainer(IContainer container):this()   {    container.Add(this);   }

  protected override void OnPopup(EventArgs args)   {    base.OnPopup(args);    this.Focus();   }    }

[VB.NET] Public Class CustomPopupControlContainer   Inherits Syncfusion.Windows.Forms.PopupControlContainer   Public  Sub New()     End Sub   Public  Sub New(ByVal container As IContainer) : Me()    container.Add(Me)   End Sub     Protected Overrides  Sub OnPopup(ByVal args As EventArgs)    MyBase.OnPopup(args)    Me.Focus()   End Sub   End Class

It is also necessary to specify the parent-child relationship between the ComboBoxBase’s popup and the PopupControlContainer. This could be done by handling the ComboBoxBase’s drop-down event as shown in the code sample below:

[C#] private void comboBoxBase1_DropDown(object sender, System.EventArgs e)  {        /* Setup the relationship between the ComboBoxBase’s dropdown and it's parent                PopupControlContainer, so that the popup will not close when the ComboBoxBase’s            dropdown is shown */

  this.comboBoxBase1.PopupContainer.PopupParent = this.popupControlContainer1;   this.popupControlContainer1.CurrentPopupChild = this.comboBoxBase1.PopupContainer;  }

[VB.NET] Private  Sub comboBoxBase1_DropDown(ByVal sender As Object, ByVal e As System.EventArgs)

'         Setup the relationship between the ComboBoxBase’s dropdown and it's parent         '        PopupControlContainer, so that the popup will not close when the ComboBoxBase’s     '        dropdown is shown      Me.comboBoxBase1.PopupContainer.PopupParent = Me.popupControlContainer1   Me.popupControlContainer1.CurrentPopupChild = Me.comboBoxBase1.PopupContainer End Sub

Article ID: Published Date: Last Revised Date: Platform: Control:
1080 04/30/2011 07/10/2014 Windows Forms PopupControlContainer
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.