简体   繁体   English

C#.net中的弹出窗口

[英]Popup window in C#.net

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. 我想让winform放在屏幕的中央,并且整个背景屏幕都应该模糊。 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. 使用Winforms。

Make a new windows form. 制作一个新的Windows窗体。 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

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 对于模糊效果,已在此处发布了解决方法

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. 您还可以使用计时器控制子窗体的透明度,并通过单击计时器增加子窗体的功能,使其更具动态性和交互性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM