VS 2005 Issue with multiple tab pages with databound cotrols-VBForums
Results 1 to 3 of 3

Thread: Issue with multiple tab pages with databound cotrols

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    12

    Issue with multiple tab pages with databound cotrols

    I have a tabcontrol and two tab pages on the tab control. There are some fields on the tab pages which are databound to access database table which are populated using dataadapter. There is functionality to calculate total of the fields on both the tab pages when I click a button. When I load the form the record is retrieved and all the fields are populated with data. when I click the button without navigating to the second tab page then the total is calculated only for the fields that are on the front (first) tab page. It does not include the fields on the second tab page in calculations. When I navigate on the second tab page and then hit the button then the calculations are correct.
    I saw that, for the cotrols on the second tab page, databinding does not happen until I navigate to the tab page. When I navigate to the second tab page then only the controls get the data. And this makes the difference in calculations when I just load the data and hit the button. It thus takes only the fields from the first tab page in calculation as the fields on the second tab pages are still not populated with data.

    I want the fields on the second tab page also to get populated with data as soon as the data is loaded and not when I actully navigate to the tab page.
    Any solution to this problem?

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    87,220

    Re: Issue with multiple tab pages with databound cotrols

    The TabControl is designed that way for efficiency, i.e. it doesn't create controls on pages that may never be viewed. One option would be to display the second page by default and then switch to the first page when the form is loaded, forcing both pages to be created.

    The issue there is that doing it in the load event handler may be too early, in which case you'd have to do it in the Shown event handler. That occurs after the form has been displayed, so the user may see the switch. In that case, you could probably call the CreateControl method of the second TabPage to force the controls to be created.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    12

    Re: Issue with multiple tab pages with databound cotrols

    Quote Originally Posted by jmcilhinney View Post
    The TabControl is designed that way for efficiency, i.e. it doesn't create controls on pages that may never be viewed. One option would be to display the second page by default and then switch to the first page when the form is loaded, forcing both pages to be created.

    The issue there is that doing it in the load event handler may be too early, in which case you'd have to do it in the Shown event handler. That occurs after the form has been displayed, so the user may see the switch. In that case, you could probably call the CreateControl method of the second TabPage to force the controls to be created.
    Thanks for the reply. I'll try out the solution.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.