Hi,
Make to optional form background color in Visual basic.
Method 1 :
Insert 1 button and 1 color dialogbox in form. And paste the code;
Public Class Form1
Dim color1 As Color
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ColorDialog1.ShowDialog()
color1 = ColorDialog1.Color
MsgBox(color1.ToString)
Me.BackColor = color1
End Sub
End Class
Method 2:
Insert 1 Button and 5 radiobutton in form. And paste the code;
Public Class Form1
Dim color1 As Color
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If RadioButton1.Checked Then color1 = Color.White
If RadioButton2.Checked Then color1 = Color.Black
If RadioButton3.Checked Then color1 = Color.Brown
If RadioButton4.Checked Then color1 = Color.Pink
If RadioButton5.Checked Then color1 = Color.Blue
MsgBox(color1.ToString)
Me.BackColor = color1
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
RadioButton1.Text = "White"
RadioButton2.Text = "Black"
RadioButton3.Text = "Brown"
RadioButton4.Text = "Pink"
RadioButton5.Text = "Blue"
End Sub
End Class
Bye ...
No comments:
Post a Comment