On PageViewPage load; bind controls on page

2 posts, 0 answers
  1. Adrian
    Adrian avatar
    6 posts
    Member since:
    May 2009

    Posted 07 Jul 2011 Link to this post

    I want to find a way to programatically detect if a PageViewPage has just loaded so that I could bind the controls that are on that page?
    Method SelectedPageChanged works great when you click on the handle of a Page, but it is not what I am needing.

    Just so you understand my situation; I have a top level RadPageView with many PageViewPages (Section A, Section B, Section C, Section D, Section E...etc...etc). Inside each one of the PageViewPages, I have another RadPageView control with many PageViewPages of its own (Section E - Page 1, Section E - Page 2). Please see attached screenshot for details.

    For instance, when I click on one of the PageViewPages (Section E) of the top level RadPageView; I want to detect which PageViewPage of the lower level RadPageView control is visible and active, so that I can popluate all controls on that PageViewPage only, with values from the database.
    How can this be accomplished?

  2. Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 13 Jul 2011 Link to this post

    Hi Adrian,

    Thank you for contacting us.

    I tested your case using a RadPageView with two Pages. Each of the Pages contain one RadPageView instance with another two Pages. Each of the inner Pages contains two controls: either RadButtons or RadCheckBoxes.

    The following code snippet illustrates how to reach the controls in the active Page of the nested RadPageViews, i.e. the RadButtons and the RadCheckBoxes:

    public Form1()
    {
        InitializeComponent();
        new RadControlSpyForm().Show();
        this.radPageView1.SelectedPageChanged += new EventHandler(radPageView1_SelectedPageChanged);
        this.radPageView2.SelectedPageChanged += new EventHandler(radPageView1_SelectedPageChanged);
        this.radPageView3.SelectedPageChanged += new EventHandler(radPageView1_SelectedPageChanged);
    }
     
    private void radPageView1_SelectedPageChanged(object sender, EventArgs e)
    {
        RadPageViewPage selectedPage = radPageView1.SelectedPage;
     
        foreach (Control control in selectedPage.Controls)
        {
            RadPageView nestedPageView = control as RadPageView;
            if (nestedPageView != null)
            {
                RadPageViewPage selectedNestedPage = nestedPageView.SelectedPage;
                foreach (Control nestedControl in selectedNestedPage.Controls)
                {
                    SetControlsText(nestedControl);
                }
            }
        }
    }
     
    private void SetControlsText(Control control)
    {
        //implement your own logic here
        control.Text = "This Page is Active";
    }

    I hope you find this useful. Let me know whether the above suggestion helps.

    Kind regards,
    Boryana
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top