In my winforms application I have a ColorDialog control and when the user select a color, I save the Name of the color object. For a custom color value starts with FF ex: fffdfcc8 (This is a light yellow / cream color)
Some where later I want to get to the color object from the color name string, fffdfcc8 to a system.drawing.color object. How can I do this???
Dim dlgColor As New ColorDialog()
dlgColor.AllowFullOpen = True
dlgColor.AnyColor = True
If dlgColor.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
DgView.CurrentCell.Text = dlgColor.Color.Name
End If
How to create color object based on the name value in DgView.CurrentCell.Text
UPDATE2:
Adding # in front of the custom name value and using the System.Drawing.ColorTranslator.FromHtml("#" & color)
does get the job done. Not sure what to do next since to me it was not that obvious...leave it up to the moderator to decide
UPDATE: This is not a duplicate since the name value is not a hex value.
Prefix # to the custom name and use it like this should work. As indicated in the comments and updates. Thanks to Phiter Fernandes for the help.
Dim strColor = DgView.CurrentCell.Text
System.Drawing.ColorTranslator.FromHtml("#" & strColor)