|
-
Sep 19th, 2002, 10:24 AM
#1
Thread Starter
Member
Changing backcolor on a form
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.
-
Sep 19th, 2002, 01:39 PM
#2
Frenzied Member
Whats wrong with that way??
Dont gain the world and lose your soul
-
Sep 19th, 2002, 02:19 PM
#3
Thread Starter
Member
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.
-
Sep 19th, 2002, 03:03 PM
#4
You can get a color object from a color name string like this:
VB Code:
Me.BackColor = System.Drawing.Color.FromName("Red")
There are similiar functions to get it from a RGB combo and things like that.
-
Sep 19th, 2002, 09:19 PM
#5
Frenzied Member
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.
Dont gain the world and lose your soul
-
Sep 20th, 2002, 09:34 AM
#6
Thread Starter
Member
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.
-
Aug 27th, 2003, 03:53 PM
#7
Lively Member
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
-
Sep 4th, 2003, 01:36 PM
#8
Lively Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|