vb.net教程之文本框与数据校验

金沙澳门官网网址:www.js333com

VB.net 2010 视频教程 VB.net 2010 视频教程 VB.net 2010 视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > .net教程 >
  • vb.net教程之文本框与数据校验

  • 2015-01-17 22:45 来源:www.js333com
文本框与数据校验
即与文本框相关的事件。
练习:试做一个字处理软件,包括如下功能:输入内容;打开、保存文件;编辑功能(复制、剪切、粘贴);文字格式设置(字体、字号、字形、字的颜色)。
6.5复选框、单选按钮(相关vb.net教程)
复选框:可以多选与不选,灵活。
单选按钮:选且只能选择一个。
习惯通过groupbox控件结合成一组。
Checkbox: 复选框
常用属性
Checked:复选框是否被选择.
Appearance:外观样式,normal—常规外观,button—按钮外观
Flatstyle:外观风格,有四个.
常用事件:click—单击、CheckedChanged—选择变化激发的。
Radiobutton: 单选按钮
Groupbox: 控件组,用以组织控件成为一组.
应用:
例4:在文本框中输入文字,然后用单选钮控制字的颜色、字型(文字加粗、倾斜、下画线)字号(10、20、40)。[实验报告21 ]
见字体字号字形字的颜色.
注意:字的颜色可以在程序直接设置属性实现,但字号,字型则不能直接在程序中设置?(因为它们都是只读属性,只能在属性窗口中设置,而不能在程序中引用)
程序为:
  Private Sub setfont()
        Dim s As FontStyle = FontStyle.Regular
        If CheckBox1.Checked Then s = s + FontStyle.Bold
        If CheckBox2.Checked Then s = s + FontStyle.Italic
        If CheckBox3.Checked Then s = s + FontStyle.Underline
        TextBox1.Font = New Font(TextBox1.Font.Name, TextBox1.Font.Size, s)
    End Sub
    Private Sub setsize()
        If RadioButton1.Checked Then TextBox1.Font = New Font(TextBox1.Font.Name, 10)
        If RadioButton2.Checked Then TextBox1.Font = New Font(TextBox1.Font.Name, 20)
        If RadioButton3.Checked Then TextBox1.Font = New Font(TextBox1.Font.Name, 40)
    End Sub
 
    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        setsize()
    End Sub
 
    Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
        TextBox1.ForeColor = Color.Black
    End Sub
 
    Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
        TextBox1.ForeColor = Color.Red
    End Sub
 
    Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
        TextBox1.ForeColor = Color.Blue
    End Sub
 
    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        setsize()
    End Sub
 
    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        setsize()
    End Sub
 
    Private Sub CheckBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.Click
        setfont()
    End Sub
 
    Private Sub CheckBox2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox2.Click
        setfont()
    End Sub
 
    Private Sub CheckBox3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox3.Click
        setfont()
    End Sub
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        End
    End Sub
相关教程
Baidu
sogou