Yes, this is possible. Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form.
using System;
using System.Windows.Forms;
public class MyTabControl : TabControl {
private int mPages = 0;
private void checkOnePage() {
if (IsHandleCreated) {
int pages = mPages;
mPages = this.TabCount;
if ((pages == 1 && mPages > 1) || (pages > 1 && mPages == 1))
this.RecreateHandle();
}
}
protected override void OnControlAdded(ControlEventArgs e) {
base.OnControlAdded(e);
checkOnePage();
}
protected override void OnControlRemoved(ControlEventArgs e) {
base.OnControlRemoved(e);
checkOnePage();
}
protected override void WndProc(ref Message m) {
// Hide tabs by trapping the TCM_ADJUSTRECT message
if (m.Msg == 0x1328 && !DesignMode && this.TabCount == 1) m.Result = (IntPtr)1;
else base.WndProc(ref m);
}
}