Are you setting the DialogResult of the dialogue form to OK? If not then ShowDialog will not return OK so the contents of the If block will not be executed. The idea is that the user can cancel the operation if they decide not to add the tab. If you set the form's DialogResult to Cancel or just call Close, or the user clicks the Close button on the title bar, then ShowDialog returns Cancel. If you want ShowDialog to return OK then you have to make it do so by setting the form's DialogResult property.