Thursday, 19 January 2012

Button, Checkbox, Checkedlistbox, and Combo Box in vb.net


How to use the Button, Checkbox, Checkedlistbox, and Combo Box?
Button:
A button is a control, communicate the user with application which we click and release the button it can perform some actions
A button is get event when the mouse button, enter key, spacebar, if the button is focused
In vb.net we use like this
We can change the button name in vb.net
Button1.text =”change to name of the button”
If you need to create a application

  • Open fileà new project from file menu
  • Select windows application àrename the application as button controller  

  • Drag and drop the button from toolbox
The following code is used to show the” message box as your created a new button “button controller application:
Public Class Form1
    Private SubForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
        Button1.Text = "my new button"

    End Sub
    Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click
        MessageBox.Show("You’re created a new button")
    End Sub

   
End Class

Checkbox:
It checks or selects the application. You can click a check box to select it and click it again to deselect it.
Rename the Check box
Checkbox. Text=”my new check box”
If you want to do

  • Open fileà new project from file menu
  • Select windows applicationà rename the application as checkbox controller  
  • Drag and drop the checkbox from toolbox
The following code is used to show the “message box as your don” checkbox controller application:
Public Class Form1

    Private SubForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load

        CheckBox1.Text = "Show"
    End Sub

    Private SubCheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesCheckBox1.CheckedChanged
        CheckBox1.Checked = True
        MessageBox.Show("your done..!")
    End Sub
End Class

Combo Box:
The Combo Box control, which lets the user choose one of several choices from list
The combo box controller command
Combobox1.Items.add (“Sunday”)
Combobox1.Items.remove (“Sunday”)
By default you can made
Combobox1.selectedItem= combobox1.item (“select”)

  • Open fileà new project from file menu
  • Select windows applicationà rename the application as combo box controller  
  • Drag and drop the combo box from toolbox
The following code is used to show the “select the day in week” application:
Public Class Form1
    Private SubForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
        ComboBox1.Text = "-select-"
        ComboBox1.Items.Add("Sunday")
        ComboBox1.Items.Add("Monday")
        ComboBox1.Items.Add("Tuesday")
        ComboBox1.Items.Add("wednesday")
        ComboBox1.Items.Add("Thursday")
        ComboBox1.Items.Add("Friday")
        ComboBox1.Items.Add("Saturday")


    End Sub
   

End Class