Fixed stack panel header

4 posts, 1 answers
  1. Eljay
    Eljay avatar
    10 posts
    Member since:
    Dec 2011

    Posted 05 Jan 2012 Link to this post

    Is it possible to fix the stack panel header? By default, the header text reflects the selected page's text.

    I've attached the header outlined in red. Thanks.

  2. Answer
    Stefan
    Admin
    Stefan avatar
    2489 posts
    Member since:
    Sep 2012

    Posted 09 Jan 2012 Link to this post

    Hello Eljay,

    Thank you for writing.

    The text of the stack element is changed when the selected page of the control is changed. In order to make it constant text, you will have to subscribe to the TextChanged event, where you can set your own text. Here is how to do that:

        public Form1()
        {
            InitializeComponent();
     
            RadPageViewStackElement stack = radPageView1.ViewElement as RadPageViewStackElement;
            stack.Header.Text = "Custom text";
             
            stack.Header.TextChanged += new EventHandler(Header_TextChanged);
        }
     
        void Header_TextChanged(object sender, EventArgs e)
        {
            RadPageViewLabelElement label = sender as RadPageViewLabelElement;
            label.Text = "Custom text";
        }
    }

    I hope that the provided information addresses your question. Should you have any other questions, do not hesitate to contact us.

    Kind regards,
    Stefan
    the Telerik team

    SP1
    of Q3’11 of RadControls for WinForms is available for download (see what's new).

  3. Eljay
    Eljay avatar
    10 posts
    Member since:
    Dec 2011

    Posted 18 Jan 2012 Link to this post

    This works, Thanks Stefan!

    I also tried doing this by data-binding radPageView.ViewElement.Header.Text to a fixed string property, but it didn't work. Why is that?

  4. Peter
    Admin
    Peter avatar
    1144 posts
    Member since:
    Sep 2012

    Posted 23 Jan 2012 Link to this post

    Hi Eljay,

    Thank you for writing back.

    The following code demonstrates how to bind this element:

    public partial class Form1 : Form
        {
            public string Text { get; set; }
            public Form1()
            {
                InitializeComponent();
                this.Text = "aaaa";
            }
     
            private void Form1_Load(object sender, EventArgs e)
            {
                radPageView1.ViewElement.Header.Visibility = Telerik.WinControls.ElementVisibility.Visible;
                radPageView1.ViewElement.Header.DataBindings.Add("Text", this, "Text", true, DataSourceUpdateMode.OnPropertyChanged);
            }
        }

    I set the element visibility because by default the radPageView.ViewElement.Header element is not visible for some modes. 

    I hope this helps. Don't hesitate to contact us, if you have other questions.

    Regards,
    Peter
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Back to Top