Welcome Guest ( Login | Register )



All times are UTC - 7 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Changing a button's color via script
PostPosted: Mon May 14, 2012 9:53 am 

Joined: Thu May 03, 2012 9:53 am
Posts: 2

Offline
I may be missing something obvious here, but I am trying to change a button's color via script. I thought I had successfully done this before, but I can't seem to recreate it.

I have a button called Button1, and I have Button1_Click hooked into it. Inside Button1 I have two lines of code:

Code:
Button1.Text = "Button Pressed";
Button1.Fill = new BrushCF(Color.Blue);


The text is changing, but the color of the button does not change. Any suggestions on how I can do this?


 Profile  
 
 Post subject: Re: Changing a button's color via script
PostPosted: Mon May 14, 2012 10:01 am 

Joined: Thu May 03, 2012 9:53 am
Posts: 2

Offline
After trying for over an hour yesterday, I finally figured it out about 5 minutes after posting my question. I had applied a Style to the button, which meant that it no longer responded to the Script to change the color. When changing from Classic back to Default, I can change the color.

That leads me to my modified question: Is there a way to keep the Style while still being able to change the color at run-time?


 Profile  
 
 Post subject: Re: Changing a button's color via script
PostPosted: Mon May 14, 2012 10:31 am 
User avatar

Joined: Fri Jul 15, 2011 3:21 pm
Posts: 214

Offline
There's not a way to do that. The best you can do is have multiple buttons with different styles and change there visibility at run-time.

_________________
Best Regards,

Beijer Electronics, Inc.
Ron Lloyd | Applications Engineer


 Profile  
 
 Post subject: Re: Changing a button's color via script
PostPosted: Mon Dec 14, 2015 2:31 pm 

Joined: Mon Dec 14, 2015 2:27 pm
Posts: 2

Offline
Has a solution to this problem been implemented since 2012? Im running into this issue as well, and really need to keep the non standard button styling while maintaining the ability to change background color.

Is there a better simple way to change a button's background color when pressed? I just need it to maintain a latched state when pressed, with a different color.


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron