I am working on a windows form that has a TabControl named tabDocuments. I came across this piece of code that removes all pages from the TabControl.
for (in
Calling Dispose() on each of the tab pages does not actually remove them from the TabPages collection, it simply disposes them. The call to Clear() is what removes them from the collection. If you don't call Clear() they will still be there, and bad things will likely happen because you will end up trying to use them after they have been disposed.