首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

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,当用户单击是按钮

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

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

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

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

S.N.

控制& 说明

1

ColorDialogIt represents a common dialog box that displays available colors along with controls that enable the user to define custom colors.它表示一个公共对话框,显示可用颜色以及允许用户定义自定义颜色的控件。

2

FontDialogIt 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

OpenFileDialogIt prompts the user to open a file and allows the user to select a file to open.它提示用户打开文件,并允许用户选择要打开的文件。

4

SaveFileDialogIt 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

PrintDialogIt 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窗体应用程序中选择要打印的文档的哪些部分来打印文档。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com