VB.Net – 对话框

有许多内置的对话框,用于Windows窗体中的各种任务,例如打开和保存文件,打印页面,向应用程序的用户提供颜色,字体,页面设置等选择。 这些内置的对话框减少了开发人员的时间和工作量。

所有这些对话框控件类继承自CommonDialog类,并覆盖基类的RunDialog()函数以创建特定对话框。

当对话框的用户调用其ShowDialog()函数时,将自动调用RunDialog()函数。

ShowDialog方法用于在运行时显示所有对话框控件。 它返回一个DialogResult枚举类型的值。 DialogResult枚举的值为:

  • Abort 中止 – returns DialogResult.Abort value, when user clicks an Abort button.  当用户单击“中止”按钮时,返回DialogResult.Abort值。

  • Cancel 取消 -returns DialogResult.Cancel, when user clicks a Cancel button.  当用户单击Ignore按钮时,返回DialogResult.Ignore。

  • Ignore 忽略 -returns DialogResult.Ignore, when user clicks an Ignore button.  返回DialogResult.No,当用户单击否按钮。

  • No  -returns DialogResult.No, when user clicks a No button.  不返回任何内容,对话框继续运行。

  • None  -returns nothing and the dialog box continues running.  返回DialogResult.OK,当用户单击确定按钮

  • OK -returns DialogResult.OK, when user clicks an OK button.  返回DialogResult.  OK,当用户点击OK键

  • Retry 重试 -returns DialogResult.Retry , when user clicks an Retry button.  当用户单击重试按钮时,返回DialogResult.Retry

  • Yes  -returns DialogResult.Yes, when user clicks an Yes button.  返回DialogResult.Yes,当用户单击是按钮

下图显示了通用对话框类继承:

VB.Net对话框

上述所有相应控件,可以在设计期间从工具箱中添加。 您可以通过以编程方式实例化类或通过使用相关控件,将这些类的相关功能包括到应用程序中。

当双击工具箱中的任何对话框控件或将控件拖动到窗体上时,它将显示在Windows窗体设计器底部的组件托盘中,但不会直接显示在窗体上。

下表列出了常用的对话框控件。 点击以下链接查看其详细信息:

 
S.N.控制& 说明
1

ColorDialog

It represents a common dialog box that displays available colors along with controls that enable the user to define custom colors.

它表示一个公共对话框,显示可用颜色以及允许用户定义自定义颜色的控件。

2

FontDialog

It prompts the user to choose a font from among those installed on the local computer and lets the user select the font, font size, and color.

它提示用户从安装在本地计算机上的字体中选择字体,并让用户选择字体,字体大小和颜色。

3

OpenFileDialog

It prompts the user to open a file and allows the user to select a file to open.

它提示用户打开文件,并允许用户选择要打开的文件。

4

SaveFileDialog

It prompts the user to select a location for saving a file and allows the user to specify the name of the file to save data.

它提示用户选择保存文件的位置,并允许用户指定保存数据的文件的名称。

5

PrintDialog

It lets the user to print documents by selecting a printer and choosing which sections of the document to print from a Windows Forms application.

它允许用户通过选择打印机并从Windows窗体应用程序中选择要打印的文档的哪些部分来打印文档。


作者:andy,如若转载,请注明出处:https://www.web176.com/vbnet/11335.html

(0)
打赏 支付宝 支付宝 微信 微信
andy的头像andy
上一篇 2023年3月1日
下一篇 2023年3月1日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注