Monday, October 19, 2009

Convert System.Drawing.Color to HTML color

Simple utility code syntax for converting System.Drawing.Color to HTML color

/*
Runtime whenever you are trying to access color, it is easy to assign known colors, but if you want to assign HTML Color name runtime you can use ColorTranslator.FromHtml method instead of Color.KnownColor name.
*/

tdRecord.BackColor = System.Drawing.Color.Yellow;
tdRecord.BackColor = System.Drawing.ColorTranslator.FromHtml("#ecf5f8");

No comments:

Most Recent Post

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape