开发者

Making a menu (color palette) from looping through colors

开发者 https://www.devze.com 2023-02-03 06:07 出处:网络
I have the following code: foreach (Color color in new ColorConverter().GetStandardValues()) { output.Wri开发者_开发百科te(color.ToString());

I have the following code:

        foreach (Color color in new ColorConverter().GetStandardValues()) 
        { 
            output.Wri开发者_开发百科te(color.ToString()); 
        }

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


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();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号