vb.net Option Button (Circle) change color?

  • Thread starter Thread starter Roger
  • Start date Start date
R

Roger

Is this an easy thing to change?

I want to put an option button on a form and want to dynamically change the
color (Red, Yellow, Green) for
showing a status. I figured it would be an easy task, but am finding it a
little difficult as there isn't a simple property to set.

Thanks,

Rog
 
What I need to do is change the inside of the Circle color? The .background
will change the Label background, but not the inside of the circle.

Any other suggestions?

Thanks,
 
Hi,

you can change the color in the paint event, but you won't get the white
circle filled nice, I would do it like this:
Just draw a circle on the form and change it's color based on a condition,
for example place 3 radiobuttons on a form and copy paste this code

Private myBrush As New SolidBrush(SystemColors.Control)
Private myRect As New Rectangle(10, 10, 20, 20)

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) _ Handles MyBase.Paint
e.Graphics.FillEllipse(myBrush, myRect)
End Sub

Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) _ Handles RadioButton3.CheckedChanged
myBrush.Color = Color.Red
Me.Invalidate(myRect)
End Sub

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) _ Handles RadioButton1.CheckedChanged
myBrush.Color = Color.Orange
Me.Invalidate(myRect)
End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) _ Handles RadioButton2.CheckedChanged
myBrush.Color = Color.Green
Me.Invalidate(myRect)
End Sub


Hth

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top