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

Fixed stack panel header

3 Answers 151 Views
PageView
This is a migrated thread and some comments may be shown as answers.
Eljay
Top achievements
Rank 1
Eljay asked on 06 Jan 2012, 02:36 AM
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.

3 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 09 Jan 2012, 03:37 PM
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).
0
Eljay
Top achievements
Rank 1
answered on 18 Jan 2012, 07:08 PM
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?
0
Peter
Telerik team
answered on 23 Jan 2012, 12:48 PM
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).

Tags
PageView
Asked by
Eljay
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Eljay
Top achievements
Rank 1
Peter
Telerik team
Share this question
or