Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8062667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:44:49+00:00 2026-06-05T10:44:49+00:00

Ok, I’m about googled out. I have made a mistake it would seem, by

  • 0

Ok, I’m about googled out. I have made a mistake it would seem, by designing the system before testing to see if it really works. Basically, I am providing a prompt to a color dialog to get a user selected color. I’m using this code:

ColorDialog MyDialog = new ColorDialog();

// Keeps the user from selecting a custom color.
MyDialog.AllowFullOpen = false;
MyDialog.AnyColor = false;

// Allows the user to get help. (The default is false.)
MyDialog.ShowHelp = true;
MyDialog.SolidColorOnly = true;

// Open color selection dialog box
MyDialog.ShowDialog();

functionValue = MyDialog.Color.Name;
function = "highlight";
currentFunctionValue = MyDialog.Color.Name;

functionValue is defined as a string, and that holds the color which was retrieved from the database. For example, “Red”. Later on, I use this to color a cell or row of cells in a datagrid using this code:

if (ruleFunction[j] == "highlight")
{
    Color color = Color.FromName(ruleFunctionValues[j]);
    grdTransactions.Rows[i].Cells[index].Style.BackColor = color;
}

This works fine if the color name is “Red”, “Blue”, etc. However, some dialog choices returns the value of things like “ff8000” and other hexadecimal representations of the color. I guess this throws off the Color.FromName function, and the cells not only do not have a color, but have messed the text up within the datagrid cells. Is there any way to either make it display the color that was selected with the name like “ff8000”, or exclude those colors from the colorDialog selection screen? I really don’t want to create my own custom dialog with colors if I can help it. I would even go back and change how it’s stored in the database if necessary. Any help would be appreciated!

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:44:51+00:00Added an answer on June 5, 2026 at 10:44 am

    Instead of storing the name that came back, just store the color object that comes back. Then you can just assign it directly instead of going to and from string values.

    Edit: If you can’t store it as a color object, then use the integer value of ToArgb. Then you can load it using the FromArgb method.

    Color c = Color.Red;
    int redColor = c.ToArgb();
    
    //...
    
    this.BackColor = Color.FromArgb(redColor);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I would like to run a str_replace or preg_replace which looks for certain words
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.