Giving Random Colors to different panels

  • Thread starter Thread starter Kevin Kastelein
  • Start date Start date
K

Kevin Kastelein

Guest
Hi guys,

Im trying to randomly give every panel on my form a color.

This is my code so far, it gives a random color, but all panels does have the same color.


Private Function RandomizeColor() As Color
Dim rand As New Random
RandomizeColor = Color.FromArgb(rand.Next(0, 256), rand.Next(0, 256), rand.Next(0, _
256))
End Function

Private Sub Dashboard_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For Each CPanel As Object In Me.Controls
If TypeOf CPanel Is Panel Then
Cpanel.BackColor = RandomizeColor()
end if
next
end sub




I hope someone could help me out with this :)


Regards,


Kevin

Continue reading...
 
Back
Top