Results 1 to 3 of 3

Thread: Issue with multiple tab pages with databound cotrols

Hybrid View

  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
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,302

    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.

  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
  •  



Click Here to Expand Forum to Full Width