vb.net 2010入门(2)-使用较复杂的输入控件

Public Class Form1



    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        DateTimePicker1.Enabled = CheckBox1.Checked
        Label1.Text = CheckBox1.CheckState
        ComboBox1.Items.Add("CheckBox1.CheckState=" & Label1.Text)
        CheckedListBox1.Items.Add("CheckBox1.CheckState=" & Label1.Text, True)
    End Sub

    Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
        Label1.Text = DateTimePicker1.Text
        ComboBox1.Items.Add("DateTimePicker1.Text=" & Label1.Text)
        CheckedListBox1.Items.Add("DateTimePicker1.Text=" & Label1.Text, True)
    End Sub

    Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox1.SelectedIndexChanged
        Dim citems As CheckedListBox.CheckedItemCollection
        Dim myevent As Object
        citems = CheckedListBox1.CheckedItems
        ListBox1.Items.Clear()
        '为右边的列表框赋值
        For Each myevent In citems
            ListBox1.Items.Add(myevent.ToString)
        Next


    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        Dim xh As String
        xh = "1"
        If Not RadioButton1.Checked Then
            xh = "2"
        End If
        ComboBox1.Items.Add("你选中了RadioButton" & xh)
        CheckedListBox1.Items.Add("你选中了RadioButton" & xh, True)
    End Sub
End Class

  窗体如下,使用了常用的较复杂的输入控件,捕捉控件事件后,将事件做为文件设置这些控件的值


vb.net 2010入门(2)-使用较复杂的输入控件
 

3、具体代码见附件

 

你可能感兴趣的:(VB.NET)