TabPage and PictureBoxes

C

Charles A. Lackman

Hello,

I am working on a program that Adds a Tab page with a picturebox inside it
for each page of a TIF and it works well. If I have a 3 page TIF the
application add 3 TabPages and inside each TabPage Adds a PictureBox and
properly displays the Images. I also do other things like add textboxes and
drawing with the mouse which works pretty good.

The problem I am having is when I want to delete a page. When the
PictureBox is Disposed and I remove the TabPage. Somehow the PictureBox is
still seen as existant. Here is an example.

The PictureBox is as Array ReDim PictureBox(3) ' PictureBox
And so are the TabPages ReDim TabPage(3) ' TabPage

PictureBox(TabControl.SelectedIndex).Dispose() 'In this example the
selected index is 0

TabControl.TabPages.Remove(TabControl.SelectedTab)

The interface looks the way it should but,

After I Dispose the PictureBox and Remove or Dispose the TabPage and do the
following:

TestPicBox.image = PictureBox(0).image

An image show's up in TestPicBox, I can even assign it a new image
PictureBox(0).image = NewImage

Shouldn't it be distroyed?

Why is it still there?

Any suggestions will be greatly appreciated.

Thanks

Chuck
 
D

David Veeneman

I don't know about that specific problem, but I have run into problems with
the Tab control that may be related. Events and property changes often don't
work on controls if the tab on which they reside is not the selected tab.
So, in these cases, I do whatever needs to be done when the tab changes and
the tab I need becomes the selected tab.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top