Issue with top caption

4 posts, 0 answers
  1. Schmidty
    Schmidty avatar
    22 posts
    Member since:
    Jan 2007

    Posted 29 Aug 2009 Link to this post

    I'm running into a problem with the caption of the group has odd alignment when the form loads. I am using the OutlookNavPane style.

    I am programmatically expanding and selecting the first group panel group with code like this:

    RadPanelBarGroupElement group = pnlMainNav.Items[0] as RadPanelBarGroupElement; 
    if (group != null) { 
      group.Expanded = true
      group.Selected = true
      group.ContentPanel.Controls.Add(new PersonMenuPanel()); 

    Everything looks fine  at first as the caption at the top of the PanelBar is correctly named but it is not centered. Manually clicking the panel group button the text centers. I'm not sure what is causing this, but I'd like it display properly when the form loads.

    Has anyone experienced this or have a workaround/fix for this?
  2. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 31 Aug 2009 Link to this post

    Hi Schmidty,

    Thank you for writing us.

    I have tested your scenario, but unfortunately I have not been able to reproduce the erroneous behavior. However, I have prepared for you a sample code snippet which will show you how to manually change the text alignment of the RadPanelBar's caption.

      RadPanelBar panelBar = new RadPanelBar(); 
                panelBar.BackColor = Color.White; 
     
                RadPanelBarGroupElement group1 = new RadPanelBarGroupElement(); 
                group1.Caption = "Group1"
     
                RadPanelBarGroupElement group2 = new RadPanelBarGroupElement(); 
                group2.Caption = "Group2"
     
                RadPanelBarGroupElement group3 = new RadPanelBarGroupElement(); 
                group3.Caption = "Group3"
     
                panelBar.GroupStyle = Telerik.WinControls.PanelBarStyles.OutlookNavPane; 
            
                panelBar.Items.Add(group1); 
                panelBar.Items.Add(group2); 
                panelBar.Items.Add(group3); 
     
                panelBar.Bounds = new Rectangle(50, 50, 250, 350); 
                this.Controls.Add(panelBar); 
                group1.Expanded = true
                group1.Selected = true
     
                RadElement element = panelBar.PanelBarElement.Children[0]; 
                RadPanelBarVisualElement caption = element.Children[0] as RadPanelBarVisualElement; 
                if (caption != null
                { 
                    caption.TextAlignment = ContentAlignment.MiddleCenter; 
                } 

     
    This sample code snippet creates a new RadPanelBar instance in outlook style. Then I add three group elements and select the first one. Finally, I change the text alignment of RadPanelBar's caption.

    Please let me know if you need more assistance.

    I hope this helps.

    All the best,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Schmidty
    Schmidty avatar
    22 posts
    Member since:
    Jan 2007

    Posted 31 Aug 2009 Link to this post

    Hi Boyko,

    I've compiled a test application that reproduces the issue I described. I'll create a support ticket so I can submit the code.

    Thanks,

    Mark
  5. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 02 Sep 2009 Link to this post

    Hello Schmidty,

    I debugged your code and I confirm the described behavior. In order to center the text correctly, please remove the serialized CaptionTextFont property value from the designer.cs file. If you want to set the CaptionTextFont, please set it runtime after the InitializeComponent. 

    I have updated your Telerik ponts for the report. Please write me back if you need more help.

    Greetings,
    Boyko Markov
    the Telerik team
    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top