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

RadPanelBar - Programattically find height of Title Bar

8 Answers 209 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.
Cameron Hart
Top achievements
Rank 1
Cameron Hart asked on 26 Feb 2009, 09:38 PM
Hey all,

I have a FlowLayoutPanel. AutoScroll is set to True, FlowDirection is TopDown, and WrapContents is False.

Inside this FlowLayoutPanel, I have a RadPanelBar. GroupStyle is ExplorerBarStyle. There is a single Element in this RadPanelBar.

The desired functionality is: When the Element is collapsed, the RadPanelBar.Height property should be set to the height of the Element's title bar. When the Element is expanded, RadPanelBar.Height should be the sum of the title bar's Height and the element content panel's height.

Obviously I've hooked an event handler up to the GroupExpandedChanged event of the Element. I need two Height values - the Content Panel's and the Title Bar's.

I can get to radPanelBarGroupElement1.ContentPanel.Height. That's fine, and returning as expected. 

I can't for the life of me work out how to extract the height of the title bar programatically.

Alternatively, if there's an easier way to do create this functionality, I'm all ears.

8 Answers, 1 is accepted

Sort by
0
Accepted
Boyko Markov
Telerik team
answered on 02 Mar 2009, 03:38 PM
Hello Cameron Hart,

You can get an instance of RadPanelBarGroupElement's captionElement using the following syntax:
this.radPanelBarGroupElement1.GetCaptionElement(). Once you have this instance you can use the Bounds property to get the ClientRectangle of that caption element. I hope this helps.

Please let me know if you need more assistance.
 

Greetings,
Boyko Markov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Cameron Hart
Top achievements
Rank 1
answered on 02 Mar 2009, 10:55 PM
Thanks Boyko for the response.

Unfortunately, the solution you've suggested to me seems to be a little buggy.

The first time the method is called (I'm expanding the Element in my Form_Load()), the GetCaptionElement().Bounds.Height is returning 16. The caption is actually 32 pixels high - the bottom half of the caption is not visible when the PanelBar is shortened to 16 pixels.

The second time the method is called (I'm manually collapsing the Element), the GetCaptionElement().Bounds.Height is returning 31. This is better, but still off.

The third time the method is called (manually expanding the Element), the GetCaptionElement().Bounds.Height is returning 32. It continues to return 32 on each subsequent activation of the handler.

This isn't particularly urgent. I've actually hard-coded the values I need for the size of the form component into the handler. On collapse, I'm setting it to 32 myself, and on expansion I'm setting it to 183 (32 caption + 150 content + 1 for panelBar border). This is working for me, so I have my solution.

That said, it would have been nice to find a method of doing this that would consistently worked even if the size of that content panel was dynamically changing.

Feel free to let this thread languish for a while - like I said, I've got my form working the way I want. This is now more of a general curiosity thing than anything else.
0
Boyko Markov
Telerik team
answered on 05 Mar 2009, 05:07 PM
Hi Cameron Hart,

I will do my best to investigate the described behavior. Please feel free to contact me again if you have any other questions regarding RadControls for Winforms.

All the best,
Boyko Markov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Erdal
Top achievements
Rank 1
answered on 10 Mar 2009, 10:24 AM
HI,

I have a similar problem.
First related to problem above:
did You mention how to access the Radpanel itself in GroupExpandedChanged event?
because sizing the contentpanel wouldn't be enough for me due to many panels I display 

In my scenario I have one main Radpanel which contains several Radpanels with each one Group that hast it's own contentpanel
with buttons.
This was the only way to achieve a mainGroup with several elements that provide Buttons for actions
But this way is total horror:
the sizing has to be done by myself
themes are not taken over from main Radpanel
themes do not change no matter what I do
performance is poor


This is what i want to achieve:

MainPanel
  Group1
    Element1
      Action1
      Action2
    Element2
      Action3
      Action4
  Group2
...
etc.

Do You have a better solution for me?
0
Cameron Hart
Top achievements
Rank 1
answered on 10 Mar 2009, 09:22 PM
Hi Erdal,

I'm not sure if this will help you, but there's a few differenet events you might find useful in this scenario.

On the RadPanelBar:
  1. PanelBarGroupCollapsed (Fires just after the collapse happened)
  2. PanelBarGroupCollpasing (Fires just before the collapse happens - allows the collapse to be cancelled before it happens)
  3. PanelBarGroupExpanded (Fires just after the expand happened)
  4. PanelBarGroupExpanding (Fires just before the expand happens - allows the expand to be cancelled before it happens)

On the RadPanelBarGroupElement:
  1. GroupExpandedChanged (Fires just after the expand/collapsed happened)

From my experience with a single panel, my advice would be to reconsider which events you want to use. If you're having difficulty, I would reccomend using the Collapsed and the Expanded events of the RadPanelBar. It's less elegant to have two handlers when one would do, but it's also less messy.

Secondly, I would advise you to decide on the heights of your caption and content elements at design-time, and hard-code those values into your application. As detailed above, I've found that getting those values at run-time can be a bit buggy. If you want to use dynamic theming, this won't be an option and I'm not sure what you should do - I couldn't get that information myself.

That said, it's a bit hard to discern from your question exactly what you're up to. It looks like you're using the term 'RadPanel' interchangably to mean 'RadPanelBar', 'RadPanelBarGroupElement' and 'the RadPanelBarGroupElement's content panel'. It's a bit hard to know which you mean each time you use the term 'RadPanel'. Could you be a little clearer, please?

EDIT: Also, it would help to know the functionality you're going for if you told us what GroupStyle you were intending to use for any RadPanelBar.
0
Erdal
Top achievements
Rank 1
answered on 11 Mar 2009, 09:37 AM
Hi Cameron,

when I talk of RadPanel i mean Radpanellbar.
So I'm using nested RadPanelBars
Groupstyle:I used Explrorerbar which worked well but has a poor look
                  lastly I will use OutlookNavPane

MainPanel(RadPanelBar)
  Group1(RadPanelBarGroupElement)
    Element1(NEW RadPanelBar with one RadPanelBarGroupElement)
      Action1 (RadButton in Contentpanel for example)
      Action2 ...
    Element2 ..
      Action3..
      Action4 ..
  Group2..
All generated programmatically

I' Using the GroupExpandedChanged-event for Sizing the units, but sizing the contentbar did not work,
so for sizing(collapsing) I had to access the RadPanelbar(of Sub-Element) which i had to know for how to access the RadpanelBar from this event that only provides the RadPanelBarGroupElement

But my main complain is the nested RadPanelBars do not inherit anything from Main-RadPanelbar even worse the Nested
RadPanelbar comes along with no intention to react on any styling/ theming whatever
When nested RadPanelbars are supported like in tutorial shown, these should communicate with each other
NestedPanelbars
0
Cameron Hart
Top achievements
Rank 1
answered on 12 Mar 2009, 08:42 PM
I'm still a little inexperienced when it comes to changing themes around, but this could work.

Have you tried using the outer RadPanelBar's Load event to set the child RadPanelBars' theme information? Or the outer RadPanelBar's ThemeNameChanged event?

        private void outerRadPanelBar_Initialized(object sender, EventArgs e) 
        { 
            this.innerRadPanelBar.ThemeClassName = this.outerRadPanelBar.ThemeClassName; 
            this.innerRadPanelBar.ThemeName = this.outerRadPanelBar.ThemeName; 
        } 
 
        private void outerRadPanelBar_ThemeNameChanged(object source, ThemeNameChangedEventArgs args) 
        { 
            this.innerRadPanelBar.ThemeClassName = this.outerRadPanelBar.ThemeClassName; 
            this.innerRadPanelBar.ThemeName = this.outerRadPanelBar.ThemeName; 
        } 

Note I haven't actually tested if this works. It's just an idea. You may be able to comment-out lines 3 and 9. I'm not sure how Telerik Theming works at the level of runtime code, but I have a sneaking suspicion that setting the ThemeClassName in these events is redundant.

And before one of the Telerik guys get to it, I'll remind you that the theme control that you want to use must have been dragged and dropped onto the form before you can use it. Pretty sure that you know this already, but it needs to be got out of the way. May as well do it here.

It seems weird to me that this isn't working on its own, but perhaps you've stumbled on a bug? Try slapping some sample code together and stick it up in a new thread. Giving the Telerik guys something to work with is generally a good idea.
0
Boyko Markov
Telerik team
answered on 13 Mar 2009, 12:24 PM
Hello Cameron Hart,

My suggestion is to only subscribe to the ThemeNameChanged event of the outer panelbar and write the necessary code in the event handler. You need only to set the ThemeName property. Here is some sample code:

1. Subscribe to ThemeNameChanged event


this.radPanelBarDemo.ThemeNameChanged += new Telerik.WinControls.ThemeNameChangedEventHandler(radPanelBar1_ThemeNameChanged); 

2. Change the theme of the inner panel bar in the event handler:

void radPanelBar1_ThemeNameChanged(object source, Telerik.WinControls.ThemeNameChangedEventArgs args) 
   this.radPanelBar2.ThemeName = this.radPanelBarDemo.ThemeName; 
 

I hope this helps. Do not hesitate to contact me if you have further questions.

Best wishes,

Boyko Markov
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Panelbar (obsolete as of Q2 2010)
Asked by
Cameron Hart
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
Cameron Hart
Top achievements
Rank 1
Erdal
Top achievements
Rank 1
Share this question
or