Change ForeColor of radButton not working

9 posts, 2 answers
  1. Martin
    Martin avatar
    20 posts
    Member since:
    Nov 2010

    Posted 08 Nov 2010 Link to this post

    Hello,

    Fairly simple need to change the fore color of a button, neither of the following lines change the color, how may I do this ?

    cmdD1.ForeColor =

    Color.White;

     

    cmdD1.RootElement.ForeColor =

    Color.White;

     


  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 Nov 2010 Link to this post

    Hello, 

    To change the forecolor of a RadButton, you need to specify the ForeColor on the ButtonElement. 

    Me.RadButton1.ButtonElement.ForeColor = Color.Blue

    Hope that helps, but let me know if you need further help
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Martin
    Martin avatar
    20 posts
    Member since:
    Nov 2010

    Posted 08 Nov 2010 Link to this post

    Thanks for response - but this simply doesnt appear to work. The Text ForeColor remains black regardless of how I try this. I'm even checking the InvokeRequired:

     

    if (cmdNotImported.InvokeRequired)

     

    cmdNotImported.BeginInvoke((

    MethodInvoker)delegate

     

    {

    cmdNotImported.ButtonElement.ForeColor =

    Color.White;

     

     

    }

     

     

    else

     

    {

    cmdNotImported.ButtonElement.ForeColor =

    Color.White;

     

    }

    }



  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 Nov 2010 Link to this post

    Hi Martin, 

    That shouldn't be required. 
    May I ask what version of the controls you are using? And where in the code you are trying to update the ForeColor of the button? 
    Any other information will help me to resolve your issue. 

    Thanks
    Richard
  6. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 Nov 2010 Link to this post

    Also, can you confirm that you are not trying to update the ForeColor from a background thread. 
    Thanks
    Richard
  7. Martin
    Martin avatar
    20 posts
    Member since:
    Nov 2010

    Posted 08 Nov 2010 Link to this post

    Hi, I'm using version 2010.2.10.806 of the controls which is 2010 Q2 SP1 I believe.

    The ForeColor changes are done initially on the main GUI thread.

    Subsequently a timer fires (running on a seperate thread), hence the InvokeRequired check, and those updates to the button are done on the Timer thread.

    Neither seem to have any effect.
  8. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 Nov 2010 Link to this post

    Hi,

    Can you please try this very simple VB example in a new project. it's just two buttons on a form.
    If this doesn't work for you, may I suggest upgrading to the latest 914 version (though the new Q3 version is out very soon)

    let me know if that helps

    Richard

    Public Class Form1
      
        Private Delegate Sub ChangeColorHandler()
      
      
        Private Sub ChangeColor()
            If InvokeRequired Then
                Invoke(New ChangeColorHandler(AddressOf ChangebuttonColor))
            End If
        End Sub
      
        Private Sub ChangeButtonColor()
            Me.RadButton2.ButtonElement.ForeColor = Color.Green
        End Sub
      
      
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.RadButton1.ButtonElement.ForeColor = Color.Blue
      
            Dim myThread As New System.Threading.Thread(AddressOf ChangeColor)
            myThread.Start()
        End Sub
    End Class
  9. Answer
    Martin
    Martin avatar
    20 posts
    Member since:
    Nov 2010

    Posted 09 Nov 2010 Link to this post

    Richard, I have the Colors working now. I think I had a version mismatch between Q2 SP1 and SP2 that was probably throwing some first chance exceptions behind the scenes. Bringing all references to the right version and all seems to work fine now. Thanks
  10. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 09 Nov 2010 Link to this post

    Glad you have this sorted Martin. If you feel that the post answered your question, please remember to mark as answer so others can find the solution too. 

    All the best
    Richard
Back to Top
UI for WinForms is Visual Studio 2017 Ready