Popup window in C#.net

2019-03-02 17:05发布

问题:

How to popup a child form when I click the button. I want to child winform to be in the centre of the screen and the whole background screen should be blurred. and a small close button should be visible in the right corner of the form. I have searched the web but found nothing.

Using Winforms.

回答1:

Make a new windows form. it has a close button by default. Set it default position to center screen. Then on your button click.

Lets say your new form is Form2

Form2 frm = new Form2();
frm.ShowDialog();

it will not make the rest of screen blurred but user will not be able to do anything with it.

For blurry effect a workaround has been posted here



回答2:

You can trigger event from click button like this

Form form1=new Form();
form1.show;

and after that to blurr the parent screen use opacity property of and increase or decrease it accord to your requirement. you can also control the transparency of the child form using a timer and increase paacity with timer click it will make it more dynamic and interactive.