DekGenius.com
[ Team LiB ] Previous Section Next Section

TabControlmarshal by reference, disposable

System.Windows.Forms (system.windows.forms.dll)class

A TabControl is a multipage container that can be used to display several related forms in a compact manner.

The TabControl maintains a collection of TabPages and renders a set of buttons that can be used to switch between those tabs. The number of tabs in the control can be obtained through the TabCount property. You can also retrieve the SelectedTab (or the SelectedIndex in the TabPages collection).

If there are more tabs than there is room for, you can enable Multiline display to show them in multiple rows, rather than allow the default scrolling behavior. The number of these rows is available in the RowCount property. The position of the tabs relative to the container can be set with the Alignment property.

The Appearance of the tabs can be modified. The SizeMode allows you to determine whether the tabs are of a Fixed width size to their content (Normal) or run the entire width of the control (FillToRight—you must enable Multiline to use this mode). You can also enable HotTrack, which changes the appearance of the tab on mouse over. For maximum control, you can set the DrawMode to TabDrawMode.OwnerDrawFixed and bind to the DrawItem event to paint the tabs yourself. See DrawItemEventArgs for more information about owner draw in general.

If you want to support Windows XP themes, you need to ensure that the controls Appearance is set to Normal, and that you have a manifest reference for the Common Controls v6. This will cause the tabs themselves to appear correctly, but the tab page will not render with the XP-style graduated background. You must use the DrawThemeBackground() Win32 API and a custom TabPage to achieve the full themed result.

It is also worth noting that the TabControl does not work correctly with pseudotransparency. There is no known workaround for this issue.

When the current tab page changes, the SelectedIndexChanged event is raised, the old page is hidden, and the new page is made visible. Controls on the new page will raise a VisibleChanged event, but not those on the old page.

public class TabControl : Control {
// Public Constructors
   public TabControl();
// Public Instance Properties
   public TabAlignment Alignment{set; get; }
   public TabAppearance Appearance{set; get; }
   public override Color BackColor{set; get; }
// overrides Control
   public override Image BackgroundImage{set; get; }
// overrides Control
   public override Rectangle DisplayRectangle{get; }
// overrides Control
   public TabDrawMode DrawMode{set; get; }
   public override Color ForeColor{set; get; }
// overrides Control
   public bool HotTrack{set; get; }
   public ImageList ImageList{set; get; }
   public Size ItemSize{set; get; }
   public bool Multiline{set; get; }
   public Point Padding{set; get; }
   public int RowCount{get; }
   public int SelectedIndex{set; get; }
   public TabPage SelectedTab{set; get; }
   public bool ShowToolTips{set; get; }
   public TabSizeMode SizeMode{set; get; }
   public int TabCount{get; }
   public TabPageCollection TabPages{get; }
   public override string Text{set; get; }
// overrides Control
// Protected Instance Properties
   protected override CreateParams CreateParams{get; }
// overrides Control
   protected override Size DefaultSize{get; }
// overrides Control
// Public Instance Methods
   public Control GetControl(int index);
   public Rectangle GetTabRect(int index);
   public override string ToString();  // overrides System.ComponentModel.Component
// Protected Instance Methods
   protected override ControlCollection CreateControlsInstance();  // overrides Control
   protected override void CreateHandle();  // overrides Control
   protected virtual object[ ] GetItems();
   protected virtual object[ ] GetItems(Type baseType);
   protected string GetToolTipText(object item);
   protected override bool IsInputKey(Keys keyData);  // overrides Control
   protected virtual void OnDrawItem(DrawItemEventArgs e);
   protected override void OnFontChanged(EventArgs e);  // overrides Control
   protected override void OnHandleCreated(EventArgs e);  // overrides Control
   protected override void OnHandleDestroyed(EventArgs e);  // overrides Control
   protected override void OnKeyDown(KeyEventArgs ke);  // overrides Control
   protected override void OnResize(EventArgs e);  // overrides Control
   protected virtual void OnSelectedIndexChanged(EventArgs e);
   protected override void OnStyleChanged(EventArgs e);  // overrides Control
   protected override bool ProcessKeyPreview(ref Message m);  // overrides Control
   protected void RemoveAll();
   protected void UpdateTabSelection(bool uiselected);
   protected override void WndProc(ref Message m);  // overrides Control
// Events
   public event DrawItemEventHandler DrawItem;
   public event PaintEventHandler Paint;
// overrides Control
   public event EventHandler SelectedIndexChanged;
}

Hierarchy

System.Object System.MarshalByRefObject System.ComponentModel.Component(System.ComponentModel.IComponen, System.IDisposable) Control(IOleContro, IOleObject, IOleInPlaceObject, IOleInPlaceActiveObject, IOleWindow, IViewObject, IViewObject2, IPersist, IPersistStreamInit, IPersistPropertyBag, IPersistStorage, IQuickActivate, System.ComponentModel.ISynchronizeInvoke, IWin32Window) TabControl

Passed To

ControlCollection.ControlCollection(), TabPageCollection.TabPageCollection()

    [ Team LiB ] Previous Section Next Section