Baik
kali ini saya kan memposting cara membuat checkbox dab radiobutton beserta
contoh pengaruhnya saat kita pilih salah satu dari checkbox maupun radiobutton
tersebut. baiklah mari kita simak angkah-langkahnya sebagai berikut:
CheckBox dan RadioButton
1. Buat project baru, dengan nama Prak2.
2. Desain Tampilan form seperti gambar berikut ini :

3. Tambahkan kontrol ke form seperti pada gambar diatas dan atur propertinya seperti tabel berikut:
|
Object
|
Properties
|
Nilai
|
|
Form1
|
Name
Text
|
Form1
CheckBox dan RadioButton
|
|
Label1
|
Name
Autosize BorderStyle
Font
TextAlign
Text
|
Lbl_Font
False
Fixed3D
Microsoft Sans Serif, 16
Center
CheckBox dan RadioButton
|
|
GroupBox1
|
Text
|
Efek
|
|
GroupBox2
|
Text
|
Font Style
|
|
CheckBox1
|
Text
|
StrikeOut
|
|
CheckBox2
|
Text
|
Underline
|
|
RadioButton1
|
Text
|
Regular
|
|
RadioButton2
|
Text
|
Italic
|
|
RadioButton3
|
Text
|
Bold
|
|
RadioButton4
|
Text
|
BoldItalic
|
4. Klik ganda pada CheckBox1, kemudian ketikkan kode program berikut ini :
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CheckBox1.CheckedChanged
Lbl_Font.Font = New Font("Microsoft sans Serif", Lbl_Font.Font.Size, _ Lbl_Font.Font.Style Xor FontStyle.Strikeout)
End Sub
5. Klik ganda pada CheckBox2, kemudian ketikkan kode program berikut ini :
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CheckBox2.CheckedChanged
Lbl_Font.Font = New Font("Microsoft sans Serif", Lbl_Font.Font.Size, _ Lbl_Font.Font.Style Xor FontStyle.Underline)
End Sub
6. Klik ganda pada RadioButton1, kemudian ketikkan kode program berikut ini :
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RadioButton1.CheckedChanged
Lbl_Font.Font = New Font("Microsoft sans Serif", Lbl_Font.Font.Size, _ Lbl_Font.Font.Style Xor FontStyle.Regular)
End Sub
7. Klik ganda pada RadioButton2, kemudian ketikkan kode program berikut ini :
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RadioButton2.CheckedChanged
Lbl_Font.Font = New Font("Microsoft sans Serif", Lbl_Font.Font.Size, _ Lbl_Font.Font.Style Xor FontStyle.Italic)
End Sub
8. Klik ganda pada RadioButton3, kemudian ketikkan kode program berikut ini :
Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RadioButton3.CheckedChanged
Lbl_Font.Font = New Font("Microsoft sans Serif", _ Lbl_Font.Font.Size, Lbl_Font.Font.Style Xor FontStyle.Bold)
End Sub
9. Klik ganda pada RadioButton4, kemudian ketikkan kode program berikut ini :
Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RadioButton4.CheckedChanged
Lbl_Font.Font = New Font("Microsoft sans Serif", _
Lbl_Font.Font.Size, Lbl_Font.Font.Style Xor FontStyle.Bold Xor FontStyle.Italic)
End Sub
10. Jalankan aplikasi dengan menekan tombol F5 (di keyboard), atau melalui ikon Start
Debugging di toolbar, atau melalui menu Debug > Start Debuging.
11. Simpan aplikasi Anda.
Demikian Langkah-langkah
dalam pembuatan CheckBox dan RadioButton. Semoga bermanfaat untuk kita semua.
Tidak ada komentar:
Posting Komentar