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
Hex to System.Drawing.Color (for loading the colors in the picboxes)
in the ini file I've seen that some color codes in hex are less than 6 characters long:
#FF00, #0FF0
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
Code:
PictureBox1.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF")
#FF00, #0FF0