Iterate through all tab pages in tab control - how to hide this from user

 RDD wrote:

* I have a form with one TabControl with 2 TabPages, with one TextBox on each TabPage.

Result of running this Form:

* The TextBox of the visible TabPage gets bound very well, and displays the property value. BUT, the TextBox of the second TabPage remains blank.

Can somebody provide with a solution

 Mark Rideout wrote:

Just to let you know -- I'm investigating this. The problem is that the controls on the other tab pages are not created, so they are not databound yet. Windows Forms does this to ensure that controls currently not visible are not initialized. This keeps initialization from being any slower.

 

 

 Mark Rideout wrote:

I did investigate this, sorry for the delay. This behavior is by design. Both the control and its container must be created for it to be bound. 

 

 Charles Levy wrote:
In that case, I will need to iterate through all my tab pages in order to initialize all the controls before showing my form.

 

 

What is the best way to hide the form until this is complete   I have tried to use form1.hide after the initialization code and form.show after form_activated code, but I still see the form tabbing through the various pages.

 

Any suggestions

 



Answer this question

Iterate through all tab pages in tab control - how to hide this from user

  • MichaelB

    Actually, I already have tried that with:

    For Each tbpPage As TabPage In tbcRequest.TabPages

    tbcRequest.SelectedTab = tbpPage

    Next

    tbcRequest.SelectedTab = tbpGeneral

    The problem is that when I do the form.show() to load the form, everything it does is visible, including this code in the form.load event.


  • Gordie

    If you iterate through the tabpages in the Form_Load() method then you should not see any of the tabpages being selected.


  • CoDavid

    Mick,

    I'm not sure what kind of controls you have placed on your tab pages to help to simulate my problem. I also tried a one off project real quick with 6 tab pages and just some labels on each page and I get what you have been seeing also.

    The problem with this is that I have many different controls on each page along with multiple data sources (SQL server back end using stored procedures to fill the dataset tables), data grids bound to a different data view on 3 of those pages, tree views, bound comboboxes and checked list boxes and so on.

    Because there is a lot of work going on on startup on this form, my controls on each page may take a little longer to initialize than what you have done to attempt to reproduce this problem.

    Also, my form is a child form in a mdi parent form. I wouldn't have thought that this mattered, but the more information you have about what I am trying to do should help.


  • wuebbel

    I could do that but that would defeat the purpose of tabbing through the pages. I want to have the controls loading with values, which are gained by the binding.
  • Henryk

    I didn't have any databound controls on my tabcontrol. I've never done any SQL or Database work and wouldn't know where to start, but I believe this is probably what's causing it.

    Have you tried Databinding after iterating through the TabPages


  • hagan3

    A form is not displayed until the Load event is complete; the system doesnt even finish creating the form's window handle until the load event is complete, so you cant see the form. If you are seeing the form, then there is something else wrong with your code. You will need to experiment with your code and see if you can isolate how the form is being shown.

  • mindful

    I'm not seeing this behaviour. The form doesn't show until the Load() method is complete and so I don't see any Tabpage changes.

    I even threw a System.Threading.Thread.Sleep(1000) into the loop, just to slow down the tabpage changes, and all this did was make me wait to see the Form.

    I'm working in VS2003 so it's possible that this changed in VS2005, but I wouldn't think so.


  • RobDob

    I have found the problem with this form. We are using a custom form, in which the onLoad event is overridden and during which a form resizing routine is run before a call to mybase.OnLoad.

    Thanks for your help


  • Iterate through all tab pages in tab control - how to hide this from user