storing colour values

  • Thread starter Thread starter Starbuck
  • Start date Start date
S

Starbuck

Hi



Using VB.NET



I am scratching my head over a little issue that has me foxed.

We have a form which has a selection of label controls and buttons.

The idea of the form is to allow the user to select different background and
foreground colours for different events.

The user clicks background button 1 and selects a background colour via a
common dialog box, this is displayed in label 1.

They can then do the same with the foreground colour.

This part works fine, however we then need to save the selected colours in a
string for later use.

We also need to fill the labels on the form with the colours stored in the
string should the user decide to edit the settings.

The colours are then used to set the grid colours of records in a datagrid.



Can anyone advise on the best way of storing the selected foreground and
background colours in a string and also how to set the labels colours to the
values in the string.



Thanks in advance for any advise.
 
Hi Starback,
You can use System.Drawing.ColorTranslator.FromHtml to load a color using
its HTML name, which you can easily store as a string.

E.g,
Label.BackColor = System.Drawing.ColorTranslator.FromHtml("#FF0000")

You can use System.Drawing.ColorTranslator.ToHtml to get the html string
name of a Color for use in saving.

E.g,
Dim myColor as String =
System.Drawing.ColorTranslator.ToHtml(Label.BackColor)

Best regards,
Phil Harvey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top