I don't know how to describe this problem

I have a tabcontrol that has tabs added to it when a menu item is clicked.
Each of these tabs has their own set of controls.
Each tab allows a file to be opened (via FileOpenDialog).
When a file is opened, some of it's data is inserted into certain controls on the tab.
Each tab has a button that is used to close the tab (using the Remove method).
When the tab is closed and re-opened, the file is still loaded and the file's data is still present in it's respective controls.

It might be useful to know that the file is stored as a byte array. (stored in b)

What I want is when I close a tab, then I re-open it, it is displayed as if no file was opened. As if it has been opened for the first time. I thought I could use the dispose method, but I obviously misunderstood it's use.

Is there a method that can accomplish my problem
Thanks.




Answer this question

I don't know how to describe this problem

  • Paulu

    I disposed the tabpage. It didn't work though because I couldn't open it back up after it was disposed.


  • DotNet_369

    What are you disposing the tab page itself, or the controls on it or both that might be worth looking at
  • khanhnguyen99

    It sounds as though your trying to reset the Tab to the initial status.

    Simply put as a sequence of events

    1. Start Application - Tab Details Not Set
    2. open Tab - file is allowed to be opened and details shown on tab
    3. Close Tab - file data is present.
    4. Open Tab - (At the moment the file data is present, but you want it to be in same as step 2 - with no file data load)

    I think your going to need to write some code to reset the controls on the tab. I'm not sure of what controls you have on the form or how they are populated but it may be as simple as setting the .text property = "" or maybe the controls .items.clear method but you will need to write a function to reset these controls to a default state which you can call when the tab is Opened.

    More information on what controls etc. may help allow us to provide some more info.


  • HOBO59458

    I figured it out myself. I use:
    Form1.TabControl1.TabPages.Remove(Form1.TabControl1.SelectedTab)

    It works perfect. Thanks anyway.



  • I don't know how to describe this problem