Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27020

VS 2010 Problems loading .backcolor using color codes

$
0
0
I've some pictureboxes where I select the color from a colordialog and then I save the color in a settings.ini file.
When I load the program, the instruction Form1_Shown loads the colors from the settings.ini file.

When I save the colors to the ini file I transform then from System.Drawing.Color to a String (hex).
The problem when loading the colors is that some colors are loaded correctly and others no. The other pictureboxes controls don't change the color.

System.Drawing.Color to Hex
Code:

Private Function ColorConversion(colorObj As System.Drawing.Color) As String
        Return "#" & Hex(colorObj.R) & Hex(colorObj.G) & Hex(colorObj.B)
End Function

Hex to System.Drawing.Color (for loading the colors in the picboxes)
Code:

PictureBox1.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF")
in the ini file I've seen that some color codes in hex are less than 6 characters long:
#FF00, #0FF0

Viewing all articles
Browse latest Browse all 27020

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>