Multi-line group button caption

4 posts, 1 answers
  1. Guillaume Crétot Richert
    Guillaume Crétot Richert avatar
    33 posts
    Member since:
    Oct 2008

    Posted 15 Jan 2009 Link to this post

    Hi,

    I am trying to get the group button's text to display on 2 lines. I've tried setting the Text: UI element's TextWrap property to True, but that did not change anything. I cannot find any other properties that would help me.

    What next?
  2. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 19 Jan 2009 Link to this post

    Hi Guillaume Crétot Richert,

    RadPanelBar group caption does not support the TextWrap feature. I have played with RadPanelBar trying to figure out how to create a workaround. The code I've generated is the following:

    Subscribe to the Paint event of the RadPanelBar:
          1. this.radPanelBar1.Paint += new PaintEventHandler(radPanelBar1_Paint);
           
          2. In the event handler I get the group caption bounds and draw directly on it a custom text on the position I want. The sample code draws the text with TopCenter alignment and Red color.

            void radPanelBar1_Paint(object sender, PaintEventArgs e)
            {
                RadPanelBarGroupElement group = (RadPanelBarGroupElement)this.radPanelBar1.Items[0];
                Rectangle captionBounds = group.GetCaptionElement().ControlBoundingRectangle;
            
                StringFormat format = new StringFormat();
                format.LineAlignment = StringAlignment.Near;
                format.Alignment = StringAlignment.Center;
                e.Graphics.DrawString("My Custom String", group.Font, Brushes.Red, captionBounds, format );
            }


    We will consider adding the TextWrap feature in a future version of RadPanelBar. I hope this helps you. Do not hesitate to contact me back if you have more questions.

    Best wishes,
    Boyko Markov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Guillaume Crétot Richert
    Guillaume Crétot Richert avatar
    33 posts
    Member since:
    Oct 2008

    Posted 20 Jan 2009 Link to this post

    Hi there,

    I emulated the wraparound by inserting a VbCrLf in the text displayed at runtime

    myRadPanelBarGroupElement.Text = "This text" & vbcrlf & "is wrapped."

    Thanks anyway.

    Edit: I wish I could mark my own post as the answer. As it is, this thread will remained "unanswered".
  5. Nick
    Admin
    Nick avatar
    767 posts

    Posted 20 Jan 2009 Link to this post

    Hello Guillaume Crétot Richert,

    Thank you for sharing what you found with the community - we have marked your post as an answer.

    Do not hesitate to write us back if you have more questions or suggestions.

    Regards,
    Nick
    the Telerik team

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