add dynamic labels to radPanelbarGroupElement.ContentPanel

10 posts, 0 answers
  1. Kerri
    Kerri avatar
    3 posts
    Member since:
    Jul 2007

    Posted 23 Oct 2007 Link to this post

    When I add labels dynamically to the content panel, the content panel only displays the first label added.  When I convert the labels to radLabelElements and add them directly to the groupElement, all of them display but the content panel is pushed south causing my panelbar to scroll.

    This is how I add labels to the content panel (only first one shows):
    Label lbl = new Label();
    lbl.Text = "HI";
    grpElement1.ContentPanel.Controls.Add(lbl);
    Label lbl2 = new Label();
    lbl2.Text = "HI2";
    grpElement1.ContentPanel.Controls.Add(lbl2);

    This is how I add radGroupElements to the groupElement (pushes contentPanel south):
    RadLabelElement lbl = new RadLabelElement();
    lbl.Text = "HI";
    grpElement1.Items.Add(lbl);

    I would really just like to add labels to the content panel since my theme has it looking nice... Can someone please give me a tip on how to fix this?
    Thanks - Kerri
  2. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 24 Oct 2007 Link to this post

    Hi Kerri,

    It seems that because you have not set their location, all labels have a location of (0, 0). If you set the location the way illustrated in the code bellow all labels are shown:

    Label lbl1 = new Label(); 
    lbl1.Text = "Label1"
    lbl1.Location = new Point(0, 0);            this.radPanelBarGroupElement5.ContentPanel.Controls.Add(lbl1); 
     
    Label lbl2 = new Label(); 
    lbl2.Text = "Label2"
    lbl2.Location = new Point(0, 25); 
    this.radPanelBarGroupElement5.ContentPanel.Controls.Add(lbl2); 
     
    Label lbl3 = new Label(); 
    lbl3.Text = "Label3"
    lbl3.Location = new Point(0, 50);           this.radPanelBarGroupElement5.ContentPanel.Controls.Add(lbl3); 


    Thank you for writing. Do not hesitate to contact us if you need any further assistance.

    Greetings,
    Jordan
    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. Kerri
    Kerri avatar
    3 posts
    Member since:
    Jul 2007

    Posted 24 Oct 2007 Link to this post

    Yep fixed it.  Thanks.
  5. Tim
    Tim avatar
    2 posts
    Member since:
    Oct 2008

    Posted 07 May 2009 Link to this post

    I want to add RadlabelElements directly to the PanelBarGroupElement as in Kerri's example:

    RadLabelElement lbl = new RadLabelElement();
    lbl.Text = "HI";
    grpElement1.Items.Add(lbl);

    How can I do that without the pushing the content panel south behaviour?

    Thanks - Tim.

     

  6. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 11 May 2009 Link to this post

    Hello Tim,

    You should use the ContentPanel only when you add Controls and whenever the groupElement EnableHostControlMode property value is true, otherwise you should use the Items collection of RadPanelBarGroupElement to directly add any items such as RadLabelElements.

    Here is sample code demonstrating how to add a label element to RadPanelBarGroupElement

       RadLabelElement label = new RadLabelElement();
                label.Text = "test";
                this.radPanelBarGroupElement1.Items.Add(label);

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

    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.
  7. Tim
    Tim avatar
    2 posts
    Member since:
    Oct 2008

    Posted 11 May 2009 Link to this post

    Thanks, that did it.
  8. YING JANG LIN
    YING JANG LIN avatar
    14 posts
    Member since:
    Dec 2009

    Posted 08 Apr 2010 Link to this post

    Hi,

    In Tim's example.

    1,I have 3 group item . each item have 3 or 5 label , I hope can catch which label of group had clicked.

    group 1
    -----------
     g1label1
     g1label2

    group 2
     ----------
     g2label1
     g2label2
     g2label3

    2, How set space for item at group?
    group 1
    ---------
    <space2 > g1label1
     <space 2> g1label1
    group 2
    ---------
    <space3> g2label2
                .
                .
                .

    3,How to set nest group item?
        Gorup 1
        ----------
       <space 3> subgroup 1
            ------------------------
               <space 5> g1 sub1 label1
               <space 5> g1 sub1 label2
       <space 3> subgroup 2
              <space 5> g1 sub2 label1
               <space 5> g1 sub2 label2
    Gorup 2
    ----------
       <space 3> subgroup 1
            ------------------------
               <space 5> g2 sub1 label1
               <space 5> g2 sub1 label2
       <space 3> subgroup 2
              <space 5> g2 sub2 label1
               <space 5> g2 sub2 label2

    Hope can help me and code in VB.net

    Thanks

  9. Vassil Petev
    Admin
    Vassil Petev avatar
    1765 posts

    Posted 16 Apr 2010 Link to this post

    Hi YING JANG LIN,

    Please, check the panelbar documentation on how to work with the control.


    All the best,
    Vassil
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  10. YING JANG LIN
    YING JANG LIN avatar
    14 posts
    Member since:
    Dec 2009

    Posted 21 Apr 2010 Link to this post

    Hello,Vassil


    I have attahed sample file and programming.
    .
    1, I have found document without set sub group size and location and sub group item fit group size 

    2, How to separate set group font size,sub group font size and sub group item font size


    Thanks

    YJ  
  11. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 27 Apr 2010 Link to this post

    Hi YING JANG LIN,

    Please note that you are only allowed to attach images to the forum messages. This may be the reason why I cannot notice any attachments to your latest response.

    1. Please refer to our Examples application, section PanelBar >> Nested PanelBars. This examples demonstrates how to nest RadPanelBars into each other.
    2. In order to set the font of a group, let's say RadPanelBarGroupElement1, please consider the following code snippet:
    RadPanelBarVisualElement captionElement = this.radPanelBarGroupElement1.GetCaptionElement();
    captionElement.Font = new Font("Comic Sans Serif", 12, FontStyle.Strikeout);

    As to the font of the group items, assuming that your items are contained in RadPanelBarGroupElement1, follow the approach demonstrated below:
    Font font = new Font("Comic Sans Serif", 12, FontStyle.Strikeout);
    for (int i = 0; i < this.radPanelBarGroupElement1.Items.Count; i++)
    {
         this.radPanelBarGroupElement1.Items[i].Font = font;
    }


    Sincerely yours,
    Nikolay
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
UI for WinForms is Visual Studio 2017 Ready