Articles in this section
Category / Section

Is there a way for the PopupContainerControl to work without the parent control getting deactivated?

1 min read

 

Our PopupControlContainer acts as a separate container and hence the main form loses its focus when controls inside Container receives focus.One way to overcome this is to display the PopupControlContainer using Show() method than using ShowPopup() method.

In ShowPopup method,when you specify a Parent Control using ParentControl property and pass a Point.Empty location , the popup location will be dynamically determined based on the ParentControls bounds and the screen area.Inorder to get the same behaviour while using Show() method,you need to determine the popup location manually as shown below.

C#

Point point=this.popupControlContainer1.ParentControl.Location;

point.Y=point.Y +this.popupControlContainer1.ParentControl.Height ;

popupControlContainer1.Location=point;

this.popupControlContainer1.Show ();

VB

Dim point As Point=Me.popupControlContainer1.ParentControl.Location

point.Y=point.Y +Me.popupControlContainer1.ParentControl.Height

popupControlContainer1.Location=point

Me.popupControlContainer1.Show ()

Also for closing the PopupControlContainer,you can check the visibility of the control in Form's Click Event.

C#

private void Form1_Click(object sender, System.EventArgs e)

{

if(this.popupControlContainer1.Visible ==true)

{

this.popupControlContainer1.Visible =false;

}

}

VB

Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click

If Me.popupControlContainer1.Visible =True Then

Me.popupControlContainer1.Visible =False

End If

End Sub

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied