Question

I have the following code:

        foreach (Color color in new ColorConverter().GetStandardValues()) 
        { 
            output.Write(color.ToString()); 
        }

What would be the syntax to get it to show as a color palette instead of just listing the colors?

Was it helpful?

Solution

I think you're looking for something like this:

StringBuiler sb = new StringBuiler();
foreach (Color color in new ColorConverter().GetStandardValues())          
{             
  sb.Append(string.format("<div style=\"float:left;width:5px;height:5px;background-color:#{0}\"></div>". color.ColorCode));        
} 

ltrlColorPalette.Text = sb.ToString();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top