Re: Got a nagging listbox questions
From: Armin Zingler (az.nospam_at_freenet.de)
Date: 05/01/04
- Next message: Isilio Peluffo via .NET 247: "VB .NET - Help Me pls"
- Previous message: bobby j: "Got a nagging listbox questions"
- In reply to: bobby j: "Got a nagging listbox questions"
- Next in thread: bobby j: "Re: Got a nagging listbox questions"
- Reply: bobby j: "Re: Got a nagging listbox questions"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 1 May 2004 02:01:50 +0200
"bobby j" <anonymous@discussions.microsoft.com> schrieb
> I have tried everything I know, looked every where, and I still
> cannot figure out this: You see, I have a color stored in the
> registry and it shows up as say Color [red] and I cannot get that
> color out as Color.Red so that I can put it in a variable to be
> assigned to a label.backcolor The registry getvalue code I use is as
> folllows:
>
> --------------------------------------------------------------------------
----
> PanelColors = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("My
> App")
>
> Dim nameColor = PanelColors.GetValue("My App")
>
> Label1.BackColor= nameColor
You should enable Option Strict first.
- The variable type is missing
- The type cast is missing
- You are trying to assign a String to a property expecting a Color object
> --------------------------------------------------------------------------
----------------
> I get an error message saying "Specified cast is not valid"
You are storing the wrong string. The string is not parsable. You could use
System.Drawing.Color.ToKnownColor.ToString to convert a color object to a
string to store it in the registry, then use System.Drawing.Color.FromName
to convert it back from String to a Color object. Example:
Dim s As String
s = Color.Red.ToKnownColor.ToString
MsgBox(s)
s = "Blue"
Me.BackColor = Color.FromName(s)
--
Armin
How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
- Next message: Isilio Peluffo via .NET 247: "VB .NET - Help Me pls"
- Previous message: bobby j: "Got a nagging listbox questions"
- In reply to: bobby j: "Got a nagging listbox questions"
- Next in thread: bobby j: "Re: Got a nagging listbox questions"
- Reply: bobby j: "Re: Got a nagging listbox questions"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|