Setting the width of a RadProgressBarElement

2 posts, 1 answers
  1. Allan
    Allan avatar
    8 posts
    Member since:
    Jan 2008

    Posted 19 Jan 2009 Link to this post

    I have a problem setting the width of the RadProgressBarElement so it resizes automatically to the content.
    When i change the text in the element I would like it to resize so the text fits inside it instead of it diaspearing out of therighthandside.
    I have tried setting the autosize setting to any given variation, but with no result.

    Any ideas?

    Regards Allan

    PS: The RadProgressBarElement is added to a RadStatusStrip.
  2. Answer
    Victor avatar
    1358 posts

    Posted 20 Jan 2009 Link to this post

    Hi Allan,

    Thanks for writing.

    I am afraid the width of the RadProgressBarElement cannot be set automatically however you can do the same easily using some code. The work-around is to measure the string you want to set and set the size of the RadProgressBarElement to the string width. Please see the code snippet below:

    Graphics g = radStatusStrip1.CreateGraphics();  
    int width = (int)g.MeasureString(radProgressBarElement1.Text, radProgressBarElement1.Font).Width + 10;  
    radProgressBarElement1.Size = new Size(width, radProgressBarElement1.Size.Height); 

    Please write back if you have other questions.

    Kind regards,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top