惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Darknet – Hacking Tools, Hacker News & Cyber Security
N
News and Events Feed by Topic
N
News | PayPal Newsroom
SecWiki News
SecWiki News
P
Privacy International News Feed
T
Troy Hunt's Blog
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
L
LINUX DO - 热门话题
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Security Latest
Security Latest
AWS News Blog
AWS News Blog
S
Secure Thoughts
W
WeLiveSecurity
H
Heimdal Security Blog
T
Threat Research - Cisco Blogs
I
Intezer
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Security @ Cisco Blogs
G
GRAHAM CLULEY
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Spread Privacy
Spread Privacy
L
Lohrmann on Cybersecurity
C
CERT Recently Published Vulnerability Notes
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
Google Online Security Blog
Google Online Security Blog
Cisco Talos Blog
Cisco Talos Blog
雷峰网
雷峰网
Cloudbric
Cloudbric
Y
Y Combinator Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园_首页
Hacker News: Ask HN
Hacker News: Ask HN
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google DeepMind News
Google DeepMind News
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
Latest news
Latest news
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
D
Docker
Recent Announcements
Recent Announcements
博客园 - 【当耐特】
H
Help Net Security
博客园 - 司徒正美
TaoSecurity Blog
TaoSecurity Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Check Point Blog
博客园 - 叶小钗

博客园 - sizzle

ruby函数回调的实现方法 软件单元测试之我见 非空判断 在COM中使用数组参数-SafeArray[转载] 指针赋值 - sizzle - 博客园 进程的深度隐藏 文件隐藏 Windows下网络数据报的监听和拦截技术 三键屏蔽 键盘知识 如何获取当前程序文件的路径 Net Remoting[转自Bruce Zhang's Blog] 解码 XML 和 DTD 【读书笔记】[Effective C++第3版][第27条]尽量不要使用类型转换 P2P之UDP穿透NAT的原理与实现 CommandBinding用法 一段高深代码--未解 使用C#注销/关闭计算机 TEA加密算法的C/C++实现
窗体显示中Form.Show()和Form.ShowDialog()的区别
sizzle · 2007-09-12 · via 博客园 - sizzle

窗体和对话框要么是有模式的,要么是无模式的。“模式”窗体或对话框必须关闭或隐藏,然后您才能继续使用应用程序的其余部分。

显示重要消息的对话框应始终是有模式的。模式对话框的一个示例是 Visual Studio 中的“关于”对话框。MessageBox是您可以使用的一个模式窗体。有模式对话框显示出来以后,那么开始打开的窗体或对话框就不能再获得焦点了。

“无模式”窗体让您在此窗体与另一窗体之间变换焦点,而不必关闭初始窗体。用户在该窗体显示的同时可继续在任何应用程序的其他位置工作。例如:文本编辑软件里面的搜索功能,就是一个无模式的,因为搜索对话框出来以后,还可以操作编辑本文,即它不影响其他窗体获得焦点。

将窗体显示为有模式对话框用form1.ShowDialog()方法。这个方法有一个可选参数 owner,该参数可用于指定窗体的父子关系。例如:

在Form1代码段中:

Form2 f2=new Form2();

f2.ShowDialog(this);//this表示Form1当前实例

这样f2实例就和Form1实例建立了一个父子关系,可以相互通讯。

如果没有使用f2.ShowDialog(this)而直接使用的是无参的,要定义父子关系,则需要语句f2.owner=this;

   将窗体显示为无模式对话框则用form1.show()方法。

注意    如果窗体显示为有模式,则在关闭该对话框之前,不执行 ShowDialog 方法后面的代码。但是,当窗体显示为无模式时,那么该窗体显示之后,会立刻执行 Show 方法后面的代码。