PageView Control Data Binding

2 posts, 0 answers
  1. Dan
    Dan avatar
    1 posts
    Member since:
    Apr 2013

    Posted 25 Apr 2013 Link to this post

    I am developing a WinForms application using a RadPageView control with eight tabs. On each tab I have a mix of RadTextBox and RadDropDownList controls all bound to a object using a BindingSource control. When I bind an object to this datasource the SelectedValue on certain drop downs don't always bind on pages after the first one. As soon as I click on the page the SelectedValue updates and it displays the correct value. There doesn't seem to be any pattern to which drop downs have this problem and the ones that have the problem seem to periodically change.

    Does anyone know why this happens or if there is a way around it? The problem it is causing me is that when I call ValidateChildren on the form the validation is happening without the values being correct, but when I switch to the page with the error the field is correct but still shows the validation error.
  2. Peter
    Peter avatar
    1148 posts

    Posted 30 Apr 2013 Link to this post

    Hi Dan,

    Thank you for writing.

    The observed behavior is the default behavior for the Controls in Windows Forms. It seems that the control is not yet fully initialized before it is made visible. I found similar thread on StackOverflow. There is a suggestion to call the internal CreateControl method of the control to force its initialization and this worked fine on my end.
    Alternatively, you can select the desired page as you did. Here is the method:

    private static void ForceCreateControl(Control control)
        object method = control.GetType().GetMethod("CreateControl", BindingFlags.Instance | BindingFlags.NonPublic);
        object parameters = method.GetParameters();
        Debug.Assert(parameters.Length == 1, "Looking only for the method with a single parameter");
        Debug.Assert(parameters(0).ParameterType == typeof(bool), "Single parameter is not of type boolean");
        method.Invoke(control, new object[] { true });

    I hope that you find this information useful.

    All the best,
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
  3. DevCraft R3 2016 release webinar banner
Back to Top