Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am creating button at run time, and i have a color value in this(19,117,36) format, how i can use this integer value to assing color.
example
btn1.BackColor=19,117,36

tell me plz..
Posted
Updated 15-Sep-11 1:08am
v2
Comments
koolprasad2003 15-Sep-11 8:28am    
if your post is solved then accept any solutions to make it RESOLVED

This is Pretty easy enough. Try with this

C#
btn1.BackColor = Color.LightGreen;


And if u want to use integer value then you should use
VB
Color.FromArgb(19,117,36)
 
Share this answer
 
v2
you can use Integer values to assign color use following code.
use RGB color format.

C#
btn1.BackColor = System.Drawing.Color.FromArgb(19,117,36)
 
Share this answer
 
You also need to add using statement for namespace System.Drawing
 
Share this answer
 
Try This

button.background=new SolidColorBrush(Colors.Blue)

Or
C#
button.BackColor = System.Drawing.Color.Red;
 
Share this answer
 
It seems the above mentioned solutions should work out,
Since ur creating controls dyamically may be you can check the functionality by adding event handler for the same.
Add checkbox and change the color of the button on check. uncheck event.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900