HypernovaDesktop Components · docs
Binarymission
WinForms › Power Tab Strip › BinaryPowerTabPageCollection

BinaryPowerTabPageCollection

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WinForms.Controls.TabControls

The pages of a BinaryPowerTabStrip, in tab order, as returned by BinaryPowerTabStrip.TabPages.

public class BinaryPowerTabPageCollection : BinaryPowerTabPageCollectionBase<BinaryPowerTabPage>

Inherits from / implements: BinaryPowerTabPageCollectionBase<BinaryPowerTabPage>

Remarks

Adding a page here adds its tab to the strip and removing it removes the tab; the order of the collection is the order of the headers. A page is held only once – adding or inserting a page that is already here does nothing.

Removing a page here does not change the strip's selection; BinaryPowerTabStrip.RemoveTab removes a tab and selects a neighbour.

Examples

tabs.TabPages.AddRange(new[]
{
    new BinaryPowerTabPage { Text = "Accounts" },
    new BinaryPowerTabPage { Text = "Contacts" },
    new BinaryPowerTabPage { Text = "Opportunities" }
});

BinaryPowerTabPage contacts = tabs.TabPages[1];
tabs.TabPages.MoveTo(0, contacts);    // Contacts becomes the first tab

Members at a glance

Constructors
BinaryPowerTabPageCollectionCreates an empty collection. A strip creates its own; see BinaryPowerTabStrip.TabPages.
Properties
FirstVisibleTabPageGets the first page whose BinaryPowerTabPage.Visible is on.
ItemGets or sets the page at a position in the collection.
LastButOneVisibleTabPageGets the page just before the last visible page.
LastVisibleTabPageGets the last page whose BinaryPowerTabPage.Visible is on, searching back from the end.
TabPagesCurrentlyVisibleGets how many pages have BinaryPowerTabPage.Visible on.
Methods
AddAdds a page as the last tab, unless it is already in the collection.
AddRangeAdds several pages, in order, as the last tabs.
AssignReplaces the contents of this collection with new, empty pages copied from another collection. Used by the strip itself; not intended for application code.
BeginUpdateStarts a batch of changes, at the end of which EndUpdate raises one Refresh notification.
ContainsTells whether a page is in the collection.
EndUpdateEnds a batch begun with BeginUpdate, and when the outermost batch ends raises CollectionChanged once with Refresh and no page.
IndexOfGets the position of a page among the tabs.
InsertInserts a page at a position among the tabs, unless it is already in the collection.
MoveToMoves a page to a new position.
OnClearRemoves the pages one at a time, from the last, each raising Remove, then raises one Refresh.
OnCollectionChangedRaises the CollectionChanged event.
OnInsertCompleteStarts listening to the new page's BinaryPowerTabPage.TabPageChanged event, and raises CollectionChanged with Add.
OnRemoveRaises the base class's BinaryPowerTabPageCollectionBase.Removing event, stops listening to the page, and raises CollectionChanged with Remove.
OnTabPageChangedRaises CollectionChanged with Refresh when one of the pages changes, so the strip lays its headers out again.
RemoveRemoves a page, and so its tab. A page that is not in the collection is ignored.
Events
CollectionChangedOccurs when a page is added to or removed from the collection, or changes.

Constructors

BinaryPowerTabPageCollection

public BinaryPowerTabPageCollection()

Creates an empty collection. A strip creates its own; see BinaryPowerTabStrip.TabPages.

Properties

FirstVisibleTabPage

public BinaryPowerTabPage FirstVisibleTabPage

Gets the first page whose BinaryPowerTabPage.Visible is on.

Value
The page, or null if no page is visible.

Item

public BinaryPowerTabPage this[int index]

Gets or sets the page at a position in the collection.

Value
The page, or null when getting a position that is out of range; no exception is thrown.
Parameters
index
The zero-based position.
Remarks

Replacing a page through the setter does not raise CollectionChanged, so the strip is not told; remove the old page and Insert the new one instead.

LastButOneVisibleTabPage

public BinaryPowerTabPage LastButOneVisibleTabPage

Gets the page just before the last visible page.

Value
The page before LastVisibleTabPage in the collection, whether or not it is visible itself; null when LastVisibleTabPage is.

LastVisibleTabPage

public BinaryPowerTabPage LastVisibleTabPage

Gets the last page whose BinaryPowerTabPage.Visible is on, searching back from the end.

Value
The page, or null if none is found. The search stops before the first page, so when only the first page is visible this is null.

TabPagesCurrentlyVisible

public int TabPagesCurrentlyVisible

Gets how many pages have BinaryPowerTabPage.Visible on.

Value
The number of visible pages, whether or not their headers are on show.

Methods

Add

public int Add(BinaryPowerTabPage tabPageItem)

Adds a page as the last tab, unless it is already in the collection.

Parameters
tabPageItem
The page to add.
Returns

The page's zero-based position: where it was added, or where it already was.

Exceptions
System.ArgumentNullException
tabPageItem is null.

AddRange

public void AddRange(BinaryPowerTabPage[] tabPageItems)

Adds several pages, in order, as the last tabs.

Parameters
tabPageItems
The pages to add. Must not be null or contain null.
Remarks

Each page raises its own Add notification, and a single Refresh follows the batch. Unlike Add, this does not check for pages already in the collection.

Assign

public void Assign(BinaryPowerTabPageCollection collection)

Replaces the contents of this collection with new, empty pages copied from another collection. Used by the strip itself; not intended for application code.

Parameters
collection
The collection to copy.
Remarks

Each new page copies only BinaryPowerTabPage.Visible, BinaryPowerTabPage.Text and Tag – not the page's controls or appearance.

BeginUpdate

protected void BeginUpdate()

Starts a batch of changes, at the end of which EndUpdate raises one Refresh notification.

Remarks

Each call must be matched by a call to EndUpdate; batches may nest. The individual add and remove notifications are still raised during the batch.

Contains

public bool Contains(BinaryPowerTabPage tabPageItem)

Tells whether a page is in the collection.

Parameters
tabPageItem
The page to look for.
Returns

true if the page is one of the strip's tabs.

EndUpdate

protected void EndUpdate()

Ends a batch begun with BeginUpdate, and when the outermost batch ends raises CollectionChanged once with Refresh and no page.

IndexOf

public int IndexOf(BinaryPowerTabPage tabPageItem)

Gets the position of a page among the tabs.

Parameters
tabPageItem
The page to look for.
Returns

Its zero-based index, or -1 if it is not in the collection.

Insert

public void Insert(int index, BinaryPowerTabPage tabPageItem)

Inserts a page at a position among the tabs, unless it is already in the collection.

Parameters
index
The zero-based position, from 0 to Count.
tabPageItem
The page to insert.
Exceptions
System.ArgumentOutOfRangeException
index is negative or greater than Count.

MoveTo

public BinaryPowerTabPage MoveTo(int newIndex, BinaryPowerTabPage tabPageItem)

Moves a page to a new position.

Parameters
newIndex
The zero-based position the page is to take, from 0 to Count - 1.
tabPageItem
The page to move.
Returns

The page, or null if it is not in the collection.

Exceptions
System.ArgumentOutOfRangeException
newIndex is out of range. The page has already been taken out of the collection by then.
Remarks

The page is taken out and inserted again, raising Remove and then Add.

OnClear

protected override void OnClear()

Removes the pages one at a time, from the last, each raising Remove, then raises one Refresh.

Remarks

Does not raise the base class's BinaryPowerTabPageCollectionBase.Clearing event.

OnCollectionChanged

protected virtual void OnCollectionChanged(CollectionChangeEventArgs e)

Raises the CollectionChanged event.

Parameters
e
The event data.

OnInsertComplete

protected override void OnInsertComplete(int index, object tabPageItem)

Starts listening to the new page's BinaryPowerTabPage.TabPageChanged event, and raises CollectionChanged with Add.

Parameters
index
Where the page went.
tabPageItem
The page.
Remarks

Does not raise the base class's BinaryPowerTabPageCollectionBase.Inserted event.

OnRemove

protected override void OnRemove(int index, object tabPageItem)

Raises the base class's BinaryPowerTabPageCollectionBase.Removing event, stops listening to the page, and raises CollectionChanged with Remove.

Parameters
index
Where the page is.
tabPageItem
The page about to be removed.

OnTabPageChanged

protected virtual void OnTabPageChanged(object sender, EventArgs e)

Raises CollectionChanged with Refresh when one of the pages changes, so the strip lays its headers out again.

Parameters
sender
The page that changed.
e
Not used.

Remove

public void Remove(BinaryPowerTabPage tabPageItem)

Removes a page, and so its tab. A page that is not in the collection is ignored.

Parameters
tabPageItem
The page to remove. It is not disposed.
Remarks

The strip's BinaryPowerTabStrip.SelectedTabPage is not changed; use BinaryPowerTabStrip.RemoveTab to remove a tab and select a neighbour.

Events

CollectionChanged

public event CollectionChangeEventHandler CollectionChanged

Occurs when a page is added to or removed from the collection, or changes.

Remarks

Action is Add after a page is added, Remove just before one is removed, and Refresh when a page's BinaryPowerTabPage.Visible changes or after a batch (AddRange, Assign, Clear). Element is the page, or null after a batch.

The strip listens to this event to keep its tabs in step; it is raised again to the application as BinaryPowerTabStrip.TabPageSelectionChanged.