Invoke() on RabButtonElement ?

4 posts, 0 answers
  1. Delalin
    Delalin avatar
    1 posts
    Member since:
    Mar 2009

    Posted 01 Apr 2009 Link to this post


        How can I change the properties from a RadButtonElement from another thread ?


  2. Deyan
    Deyan avatar
    2147 posts

    Posted 03 Apr 2009 Link to this post

    Hello Delalin,

    Thanks for your question.

    Please take a look at the following code snippet:

    private void Form_Load(object sender, EventArgs e) 
        ThreadStart startMethod = new ThreadStart(ThreadMethod); 
        Thread myThread = new Thread(startMethod); 
    private void ThreadMethod() 
        this.radButton1.Invoke(new MethodInvoker(ChangeButtonSize)); 
    private void ChangeButtonSize() 
         this.radButton1.Size = Size.Round(new SizeF(Math.Abs(this.radButton1.Width - 1), this.radButton1.Size.Height)); 

    What I am doing is creating a Thread instance with a delegate to a method that will be executed by this thread. In this method I use the Invoke method of a RadButton that I have put onto my form. In the Invoke method I pass another delegate to a method that will reduce the width of the button by 1 pixel.

    You can read more about the Invoke method here:

    Control.Invoke() Method

    I hope this will help you to achieve your goal.

    Do not hesitate to get back to me in case of further questions.

    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Anders Bergström
    Anders Bergström avatar
    2 posts
    Member since:
    Mar 2010

    Posted 10 Mar 2011 Link to this post

    But the RadButtonElement does not expose an Invoke method, in your example you use a RadButton and not a RadButtonElement?

    I want to modify some RadButtonElements and RadRibbonBarButtonGroups in my RadRibbonBar by using a seperate thread. If I use the code snippet below in the seperate thread, the text does not appear on the RadButtonElement, which it does if I remove the threading and the invoke functionality and run it on the GUI thread directly.

        myRadButtonElement.Enabled = true;
        myRadButtonElement.ButtonFillElement.BackColor = Color.Red;
        myRadButtonElement.Text = "some text";

    What am I doing wrong? I am using the latest version of your product.

  4. Ivan Petrov
    Ivan Petrov avatar
    715 posts

    Posted 15 Mar 2011 Link to this post

    Hi Anders Bergström,

    Thank you for writing.

    I tested the code you have posted and it works fine on my side. Therefore, I would kindly ask you to send a more detailed explanation of the scenario you are using this code in or better yet a sample project.

    I am looking forward to your reply. 

    Kind regards,
    Ivan Petrov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top