How to handle PopupControlContainer deactivate behaviour in WinForms?
WinForms PopupControlContainer control is a popup type of control and by default, the pop-up will be hidden when the user clicks anywhere outside the pop up besides the control.
For example:
If user would like to restrict this, deactivate behaviour and hide it only based on certain scenario. Consider it is needed to hide PopupControlContainer, when user clicks on close button placed in PopupControlContainer, not in other scenarios.
That can be achieved by handling its event named, BeforeCloseUp.
BeforeCloseUp
This event will be triggered, before popup hides.
Following code examples demonstrates the same.
C#
// To ensure whether close button is clicked. bool CloseButtonClicked = false; void popupControlContainer1_BeforeCloseUp(object sender, CancelEventArgs e) { if (CloseButtonClicked) { e.Cancel = false; CloseButtonClicked = false; } else e.Cancel = true; }
VB
' To ensure whether close button is clicked. Private CloseButtonClicked As Boolean = False Private Sub popupControlContainer1_BeforeCloseUp(ByVal sender As Object, ByVal e As CancelEventArgs) If CloseButtonClicked Then e.Cancel = False CloseButtonClicked = False Else e.Cancel = True End If End Sub
Figure 1. Handle PopUp visibility when User clicked outside PopUpContainer with image.
I hope you enjoyed learning about how to handle PopupControlContainer deactivate behaviour in WinForms.
You can refer to our WinForms popupcontrol feature tour page to know about its other groundbreaking feature representations. You can also explore Documentation to understand how to manipulate data.
For current customers you can check out on our Winforms components from the License and Download page. If you are new to Syncfusion, you can try our 30-day free trial to check out our Winforms popupcontrol and other WinForms components.
If you have any queries or require clarifications, please let us know in the comment section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!