Programmaticaly create and style panelbar

8 posts, 0 answers
  1. Kristof
    Kristof avatar
    32 posts
    Member since:
    Oct 2006

    Posted 14 May 2007 Link to this post

    I have a panelbar on a usercontrol. This panelbar was added with the VS Designer and thus looks great. Runtime this panelbar is filled with nodes. The top level nodes look good, because they are nodes in the panelbar that was created with the designer.
    Now when I add nested panelbars runtime, they look horrible. What I do is, I enable the "EnableHostControlMode" for the top node and create a new panelbar from scratch which I add to the ContentPanel.Controls.

    My question: How do I get the nested panelbars to look the same as their parents, programmaticaly?

    Here's a piece of the code:
    else if (mftn.Nodes.Count > 0)
    {
        rpgeToAdd.EnableHostControlMode =
    true;
        rpgeToAdd.ContentPanel.Dock =
    DockStyle.Fill;
        rpgeToAdd.ContentPanel.BackColor = System.Drawing.
    Color.Transparent;

        Point location = new Point(0, 0);
        for (int i = 0; i < mftn.Nodes.Count; i++)
        {
            RadPanelBar newNode = BuildPanelbarElementNode(mftn.Nodes[i]);
            newNode.Size =
    new Size(100, 100);
            newNode.Location = location;
            locaction.Y += 100;
            rpgeToAdd.ContentPanel.Controls.Add(newNode);
         }
    }

    private RadPanelBar BuildPanelbarElementNode(MeterFunctionTreeNode mftn)
    {
        RadPanelBar panelBar = new RadPanelBar();
        panelBar.ThemeClassName = "Telerik.WinControls.UI.RadPanelBar";

        panelBar.ThemeName = "Telerik";

        panelBar.Style = functionTree.Style;
        panelBar.BackColor = System.Drawing.
    Color.Transparent;
        panelBar.RootElement.BackColor = System.Drawing.
    Color.Transparent;

  2. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 14 May 2007 Link to this post

    Hello Kristof,

    Thank you for your question.

    Could you please send me (in a support ticket) a sample project which shows the behavior you've described? This way I will be able to offer you up-to-the-point help. Basically, I need more information about your PanelBar's Style (Listbar, OutLook, VS2005ToolBox, ExplorerBar) and why you set the ContentPanel's Dock property to DockStyle.Fill. This property will make the content panel wrap around the parent PanelBar control and the panel bar will look horrible indeed.

    You could take a look at the following code demonstrating how to add a new RadPanelBar control with two Groups to a RadPanelBarGroupElement:
     
    RadPanelBar panelBar = new RadPanelBar(); 
    panelBar.Size = new Size(100, 100); 
     
    RadPanelBarGroupElement group = new RadPanelBarGroupElement(); 
    group.Caption = "Group1"
    panelBar.Items.Add(group); 
     
    RadPanelBarGroupElement group2 = new RadPanelBarGroupElement(); 
    group2.Caption = "Group2"
    panelBar.Items.Add(group2); 
     
    this.radPanelBarGroupElement1.EnableHostControlMode = true
    this.radPanelBarGroupElement1.ContentPanel.Controls.Add(panelBar); 

    I hope this helps.

     
    Sincerely yours,
    Ray
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Kristof
    Kristof avatar
    32 posts
    Member since:
    Oct 2006

    Posted 14 May 2007 Link to this post

    Hello Ray,

    thanks for the quick reply! The code exemple you posted perfectly demonstrates my problem: The panelbar that is added looks grey and laks any mouseover effects etc. It doesn't inherit any properties from it's parent.

    I don't know how to add an image here, so I uploaded a screenshot to my own website. You can find it here:
    www.gridlock.nl/telerik/telerik.JPG

    As you can see, the parent control looks all flashy, but the panelbar from the sample code doesn't seem to have a theme or style at all.

    Thanks again for looking into this.

    Kind Regards,

    Ben van Riemsdijk
    (Kristof is a collegue)
  5. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 14 May 2007 Link to this post

    Hi Kristof Smits,

    Indeed the panel bar inside is gray because there is no theme set to it. You will have to set its ThemeName property to any of the predefined themes (ControlDefault, Office2007Black, Office2007Silver, Telerik). The example below demonstrates how to achieve that:
     
    panelBar.ThemeName = "ControlDefault"

    If you need any further assistance we will be happy to help you.

     
    Regards,
    Ray
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Kristof
    Kristof avatar
    32 posts
    Member since:
    Oct 2006

    Posted 16 May 2007 Link to this post

    Thanks, it certainly works in the example code now. Weird, because I already tried it before as you can see in the code in my first post.
  7. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 16 May 2007 Link to this post

    Hello Kristof Smits,

    I am happy I was able to help you with your issues.
    If you have any  proposals about adding new features or if you think that something in
    RadPanelBar needs to be improved please do not hesitate to write us back.



    Best wishes,
    Ray
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Kristof
    Kristof avatar
    32 posts
    Member since:
    Oct 2006

    Posted 16 May 2007 Link to this post

    I finally got the issue sorted about the looks. I have one other question though: When adding a panelbar to a RadPanelBarGroupElement, I need to specify a size, otherwise it wont show.

    But, at runtime it is impossible for me to specify the size, since the control is built up like an explorer tree, recursively etc. Is there any way to set the panelbar size to the available space? Because now I get several scrollbars if there are multiple levels of nested panelbars.

    Any ideas are greatly appreciated :)

  9. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 16 May 2007 Link to this post

    Hello Kristof,

    You will always have to set RadPanelBar's size property explicitly in the RadPanelBarGroupElement, and you can also set it to the size of the panel which hosts the control.

    I've modified a bit the code I had sent you before. The following code segment demonstrates how to add the child RadPanelBar to a RadPanelBarGroupElement and fit it to the available size in the group:
     
    RadPanelBar panelBar = new RadPanelBar(); 
     
    RadPanelBarGroupElement group = new RadPanelBarGroupElement(); 
    group.Caption = "Group1"
    panelBar.Items.Add(group); 
     
    RadPanelBarGroupElement group2 = new RadPanelBarGroupElement(); 
    group.Caption = "Group2"
    panelBar.Items.Add(group2); 
     
    panelBar.ThemeName = "ControlDefault"
    this.radPanelBarGroupElement1.EnableHostControlMode = true
    this.radPanelBarGroupElement1.ContentPanel.Controls.Add(panelBar); 
     
    panelBar.Size = this.radPanelBarGroupElement1.ContentPanel.Size; 
     



    Regards,
    Ray
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top
UI for WinForms is Visual Studio 2017 Ready