Author Topic: Changing the Look of a Button  (Read 2096 times)

Arvanoss

  • Newbie
  • *
  • Posts: 30
    • View Profile
Changing the Look of a Button
« on: February 26, 2024, 08:02:15 AM »
Good Morning Everyone,

I have a working project that the operators are asking for a change.

I have several Basic Buttons that are Enabled and Disabled based on the machine condition.  The operators would like the Disabled state to be a different color as they are having trouble determining if the button is Disabled.

Is there some code I can add to the button to change the color when Disabled??

Thanks

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Changing the Look of a Button
« Reply #1 on: February 26, 2024, 10:01:06 AM »
You can use the PLCAddressAhighlight property to change the color. Put the same address as used in PLCAddressEnabled

Arvanoss

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Changing the Look of a Button
« Reply #2 on: February 27, 2024, 06:32:16 AM »
Thanks Archie,

I am using the PLCAddressHighlightX and PLCAddressSelectTextAlternate to display reactions to the button press, these are basic Jog and Run buttons.

Is there an option/method to add a "Enable Forecolor" and "Enable Backcolor"?

Thanks

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Changing the Look of a Button
« Reply #3 on: February 28, 2024, 02:37:34 PM »
- In Solution Explorer expand down AdvancedHMIControls
- Exapand down the Controls folder
- Right Click BasicButton.vb and select View Code
- Go down to about line 405, just below #Region "Events"
- Add this code
Code: [Select]
    Protected Overrides Sub OnEnabledChanged(e As EventArgs)
        MyBase.OnEnabledChanged(e)

        If Not Me.Enabled Then
            Me.BackColor = Color.Black
        End If
    End Sub

Arvanoss

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Changing the Look of a Button
« Reply #4 on: March 04, 2024, 05:53:29 AM »
Thank you Archie that works very well.