深入浅出VB.NET提示对话框[组图](4)
组件类型组件名称属性设置结果
Form Form1Text利用MsgBox函数制作提示框
MaximizeBoxFalse
MinimizeBoxFalse
GroupBoxGroupBox1 Text显示图标
GroupBoxGroupBox2 Text 显示按钮
GroupBoxGroupBox3 Text 缺省焦点按钮
RadioButtonRadioButton1Text关键符号
RadioButtonRadioButton1Checked True
RadioButton2Text惊叹符号
RadioButton3Text 信息符号
RadioButton4Text 问号
RadioButton5Text 终止重试忽略
RadioButton6Text 是否取消
RadioButton7Text 是否
RadioButton8 Text 重试取消
RadioButton9Text 确定取消
RadioButton10CheckedTrue
RadioButton10 Text确定
RadioButton12 Text第三按钮
RadioButton13Text第二按钮
RadioButton14Text 替换
RadioButton14 Checked True
TextBox TextBox1Text
TextBox2Text
TextBox3Text
表05:【利用MsgBox函数制作提示框】项目中组件主要属性设定数值表
在设定完组件中的主要属性值后,再按照图02所示中各组件的位置和排列顺序来调整组件在设计窗体中的位置和排列顺序。
8. 把Visual Basic .Net的当前窗口切换到Form1.vb的代码编辑窗口,并在Form1.vb中的New过程代码区最后部分添加下列代码,下列代码是指定Icon_Click、Button_Click和Default_Click三个过程委托来集中处理RadioButton组件的Click事件:
AddHandler RadioButton1.Click, AddressOf Icon_Click
AddHandler RadioButton2.Click, AddressOf Icon_Click
AddHandler RadioButton3.Click, AddressOf Icon_Click
AddHandler RadioButton4.Click, AddressOf Icon_Click
AddHandler RadioButton5.Click, AddressOf Button_Click
AddHandler RadioButton6.Click, AddressOf Button_Click
AddHandler RadioButton7.Click, AddressOf Button_Click
AddHandler RadioButton8.Click, AddressOf Button_Click
AddHandler RadioButton9.Click, AddressOf Button_Click
AddHandler RadioButton10.Click, AddressOf Button_Click
AddHandler RadioButton12.Click, AddressOf Default_Click
AddHandler RadioButton13.Click, AddressOf Default_Click
AddHandler RadioButton14.Click, AddressOf Default_Click
9. 在创建Form1窗体的组件的代码区,定义下列变量,下列变量是设定程序中制作的信息对话框缺省的组成元素:
Dim MsgIcon As MsgBoxStyle = MsgBoxStyle.Critical
Dim MsgButton As MsgBoxStyle = MsgBoxStyle.OKOnly
Dim DefaultButton As MsgBoxStyle = MsgBoxStyle.DefaultButton1
10. 在Form1.vb中添加Button1组件的Click事件,并在Button1组件的Click事件的代码区添加下列代码:
Dim iResult As Integer = MsgBox ( textBox1.Text , MsgIcon + MsgButton + DefaultButton , textBox2.Text )
'显示定制的信息对话框
Select Case iResult
Case 1
TextBox3.Text = "选择""确定""按钮"
Case 2
TextBox3.Text = "选择""取消""按钮"
Case 3
TextBox3.Text = "选择""终止""按钮"
Case 4
TextBox3.Text = "选择""重试""按钮"
Case 5
TextBox3.Text = "选择""忽略""按钮"
Case 6
TextBox3.Text = "选择""是""按钮"
Case 7
TextBox3.Text = "选择""否""按钮"
End Select
'处理返回值
- 上一篇:VB中控件大小随窗体大小变化
- 下一篇:用VB6.0编写手机短信发送




