PDA

Click to See Complete Forum and Search --> : Changing backcolor on a form


stevemelaaron
Sep 19th, 2002, 10:24 AM
I have a form with a trackbar control on it, the minimum value set to 0 and the maximum value set to 15. Each time the user changes the value of the trackbar by moving the slider, I would like to change the background color of the form that it is on to one of the 16 QBColors. In VB6, I was able to accomplish this with the statement

Me.Backcolor = QBColor(Slider1.Value)

However, in VB.NET, the only way that I have been able to accomplish the same effect is through a SELECT....CASE structure

Select Case Trackbar1.Value

Case 0:
Me.Backcolor = System.Drawing.Color.Black
Case 1:
Me.Backcolor = System.Drawing.Color.Blue
Case 2:
Me.Backcolor = System.Drawing.Color.Green
(etc.....)

End Select

Is there another more elegant way to do this without having to use the SELECT...CASE structure in VB.NET?

--Steve K.

DevGrp
Sep 19th, 2002, 01:39 PM
Whats wrong with that way??

stevemelaaron
Sep 19th, 2002, 02:19 PM
Probably nothing, it just seemed overly complicated given the simple, one-line solution that I had been using in VB6. I figured that perhaps I was overlooking a simpler way to do it (being as I'm new to VB.NET).

Thanks for the response!

--Steve K.

Edneeis
Sep 19th, 2002, 03:03 PM
You can get a color object from a color name string like this:

Me.BackColor = System.Drawing.Color.FromName("Red")


There are similiar functions to get it from a RGB combo and things like that.

DevGrp
Sep 19th, 2002, 09:19 PM
VB.NET is fully object oriented, so things that were simple in VB6, might not be so simple in .NET, since its applying OO rules.

stevemelaaron
Sep 20th, 2002, 09:34 AM
I am beginning to get the idea that things are not quite as simple sometimes in VB.NET. My concern is whether or not I'm doing things "right" or not. Just as is with my original question - you can certainly accomplish changing the backcolor with the SELECT...CASE structure, but I wanted to be sure that I wasn't doing things the hard way.

Thanks for the responses on this question!

--Steve K.

Corinne
Aug 27th, 2003, 03:53 PM
Can anyone point out a place to get the numbers for a color. I need to find the exact match for a background I have selected & I'm not good enough with trying to go through and match it with custom colors. The color I am trying to match is LightSteelBlue.

Thanks,
Corinne

Corinne
Sep 4th, 2003, 01:36 PM
I came up with a site to help me with this. Maybe someone else is looking for the same thing:

http://www.webcolors.freeserve.co.uk/mixer.htm