RadLabel - Calculate Size

4 posts, 0 answers
  1. Doug
    Doug avatar
    50 posts
    Member since:
    Jul 2012

    Posted 17 Jul 2013 Link to this post

    I have a user control with a TableLayoutPanel that has two columns (and one row).  One column is autosize, the other is absolute.  There is a RadLabel in the cell in the autosize column.  I'm programmatically loading a number of these user controls onto a FlowLayoutPanel.  They resize their widths if the user resizes the form.

    I'm loading the text on the RadLabel from the database.  I would like to make the label figure out its size (width = FlowLayoutPanel's column width, height = whatever it takes to contain the text).  Then fix the height of the FlowLayoutPanel and the user control to be able to contain that RadLabel.

    I have been looking all over the forum but I haven't figured out the magic combination of properties and calculations to make this work.  Can it be done?

    Thank you,
    Gary
  2. Paul
    Admin
    Paul avatar
    60 posts

    Posted 22 Jul 2013 Link to this post

    Hi Gary,

    Thank you for writing.

    This is not supported out of the box because TableLayoutPanel has own custom logic to control the size of inner Microsoft controls and this logic is not compatible with our controls.
    In order to achieve what you need, you may control the MaxSize of the RadLabel. You should do that when you add the controls, and later when the user resizes the form.
    I have attached a sample project showing everything in action.

    Hope that helps. Please do not hesitate to contact us, should you need further assistance.

    Regards,
    Paul
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Doug
    Doug avatar
    50 posts
    Member since:
    Jul 2012

    Posted 22 Jul 2013 Link to this post

    Thank you, Paul.

    I had discovered the MaxSize property and I was experimenting with that.  I would not have guessed that I needed to work with RadLabel.LabelElement.MaxSize.

    Now I have things working almost the way I want.  Since I'm still developing the UI and the design is still in progress, I'll return to the details that I still need to work out later.  But your example got me exactly what I need.
  5. Paul
    Admin
    Paul avatar
    60 posts

    Posted 24 Jul 2013 Link to this post

    Hello Gary,

    Thank you for writing back.

    I am glad I could help. If you run in difficulties during the development we will do our best to assist you.

    Best of luck with your projects.

    Regards,
    Paul
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top