This is a migrated thread and some comments may be shown as answers.

Programmaticaly create and style panelbar

7 Answers 198 Views
Panelbar (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kristof
Top achievements
Rank 1
Kristof asked on 14 May 2007, 09:33 AM

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;

7 Answers, 1 is accepted

Sort by
0
Boyko Markov
Telerik team
answered on 14 May 2007, 12:34 PM
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
0
Kristof
Top achievements
Rank 1
answered on 14 May 2007, 02:17 PM
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)
0
Boyko Markov
Telerik team
answered on 14 May 2007, 03:46 PM
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
0
Kristof
Top achievements
Rank 1
answered on 16 May 2007, 06:32 AM
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.
0
Boyko Markov
Telerik team
answered on 16 May 2007, 09:47 AM
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
0
Kristof
Top achievements
Rank 1
answered on 16 May 2007, 11:00 AM
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 :)

0
Boyko Markov
Telerik team
answered on 16 May 2007, 04:13 PM
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
Tags
Panelbar (obsolete as of Q2 2010)
Asked by
Kristof
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
Kristof
Top achievements
Rank 1
Share this question
or