Changing the color on the selected RadPanelBarGroupElement.

3 posts, 0 answers
  1. daveo
    daveo avatar
    2 posts
    Member since:
    Jun 2007

    Posted 07 Jun 2007 Link to this post

    Hi,
    I'm trying to do something which seems trivial, but I'm having the hardest time.  I have a RabPanelBar in list mode which I programmatically add RadPanelBarGroupElements to (note I have also tried to add via the designer with the same results), when on element is selected I want the header to change color and stay.

    I have used the VSB to create a new theme which sets the FillPrimitive of ElementWithCaptionLayout of RadPanelBarGroupdElement.  THe theme uses different combinations of conditions (IsMouseOver and Selected) to set the color.  The problem is, it seems this part of the theme is not honored.  I can change other things in the theme and it works.

    Any info or direction is much appreciated.

    Thanks,
    daveo
  2. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 11 Jun 2007 Link to this post

    Hello daveo,

    I could suggest you the following solution:
     
    1. Handle the GroupExpandedChanged event of each RadPanelBarGroupElement, e.g.

          foreach(RadPanelBarGroupElement group in this.radPanelBar1.Items )  
          {  
              group.GroupExpandedChanged += new EventHandler(group_GroupExpandedChanged);  
          }     
       
       
       
    2. Change the color of the expanded group:
       
      private RadPanelBarGroupElement lastSelectedGroup;  
               
              private void group_GroupExpandedChanged(object sender, EventArgs e)  
              {  
                  if (this.lastSelectedGroup != null)  
                  {  
                      FillPrimitive lastgroupFill = this.lastSelectedGroup.Children[2].Children[0] as FillPrimitive;  
       
                      lastgroupFill.ResetValue(FillPrimitive.BackColorProperty);  
                      lastgroupFill.ResetValue(FillPrimitive.BackColor2Property);  
                      lastgroupFill.ResetValue(FillPrimitive.BackColor3Property);  
                      lastgroupFill.ResetValue(FillPrimitive.BackColor4Property);  
                  }  
       
       
                  // resets the theme  
                  string theme = this.radPanelBar1.ThemeName;  
                  this.radPanelBar1.ThemeName = "no theme";  
                  this.radPanelBar1.ThemeName = theme;  
       
                  RadPanelBarGroupElement group = sender as RadPanelBarGroupElement;  
       
                  if (group == null)  
                      return;  
       
                  this.lastSelectedGroup = group;  
       
                  FillPrimitive groupFill = group.Children[2].Children[0] as FillPrimitive;  
       
                  // changes the backColor properties of the expanded group  
                  if (!group.Expanded)  
                  {        
                      groupFill.BackColor = Color.Black;  
                      groupFill.BackColor2 = Color.Black;  
                      groupFill.BackColor3 = Color.Black;  
                      groupFill.BackColor4 = Color.Black;  
                    
                  }  
              }  
       
       
       

       

    I hope this helps. If I could be of further assistance to you please write back.


    Best wishes,

    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. daveo
    daveo avatar
    2 posts
    Member since:
    Jun 2007

    Posted 11 Jun 2007 Link to this post

    Thanks,
    I had to change a few minor things to get the exact behavior I wanted.  This was extremly helpfull, especially considering I wanted to control this programmatically instead of using a theme.

    Thanks again,
    daveo
Back to Top