Nevron User Interface 4.0 introduces a new control called NTabStrip. This is a generic control that can be used for different purposes. For example, Nevron TabControl uses such a control in order to select tab pages. Or the Nevron Docking Panels use such strips to switch among panels. With the help of this control it is a matter of a few lines of code to create tabbed MDI.
The NTabStrip control is a collection of NTab objects. This is a generic object which contains basic visualization properties like bounds, text, image index and an additional data property Param. Tab appearance is controlled at parent level - TabStyle, TabAlign, etc. Each tab calculates the rectangles where to draw text and image according to its current appearance.
The following example demonstrates how to create and visualize a tab:
C# |
Copy Code
|
NTab tab = new NTab();
tab.Tag = myData;
tab.Text = "Document 1";
tab.ImageIndex = 0;
this.nTabStrip1.Tabs.Add(tab);
|
Visual Basic |
Copy Code
|
Dim tab As NTab = New NTab()
tab.Tag = myData
tab.Text = "Document 1"
tab.ImageIndex = 0
this.nTabStrip1.Tabs.Add(tab)
|
The Nevron TabStrip control provides a great number of tab appearance customization properties. You can even control the orientation of the text - by default it is set to automatic and is drawn vertical or horizontal depending on the current tab alignment. For more information about these features see NTabStrip properties. The control also supports tab reordering (by default set to false) - using the left mouse button the user can change tab's index in its parent collection. By default a focus rectangle is drawn around the text rect of the currently selected tab but this is user-definable via the ShowFocusRect and Selectable properties.
The following example creates a NTabStrip control and customizes its appearance:
C# |
Copy Code
|
NTabStrip strip = new NTabStrip();
strip.TabStyle = TabStyle.Buttons;
strip.TabAlign = TabAlign.Bottom;
strip.HotTrack = false;
strip.ShowFocusRect = false;
strip.AllowTabReorder = true;
strip.TabFitMode = TabFitMode;
|
Visual Basic |
Copy Code
|
Dim strip As NTabStrip= New NTabStrip()
strip.TabStyle = TabStyle.Buttons
strip.TabAlign = TabAlign.Bottom
strip.HotTrack = False
strip.ShowFocusRect = False
strip.AllowTabReorder = True
strip.TabFitMode = TabFitMode
|
The tab strip functionality is exposed by the SelectedTab and SelectedIndex properties and the SelectedTabChanged event.
The following example demonstrates how to use the functionality exposed by the control:
C# |
Copy Code
|
NTabStrip strip = new NTabStrip();
strip.SelectedTabChanged += new EventHandler(OnSelectedTabChanged);
...
private void OnSelectedTabChanged(object sender, EventArgs args)
{
NTabStrip strip = sender as NTabStrip;
Debug.WriteLine("Currently selected index is: " + strip.SelectedIndex);
}
|
Visual Basic |
Copy Code
|
Dim strip As NTabStrip = New NTabStrip()
AddHandler SelectedTabChanged, AddressOf OnSelectedTabChanged
...
Private Sub OnSelectedTabChanged(ByVal sender As Object, ByVal args As EventArgs) Handles strip.SelectedTabChanged
Dim strip As NTabStrip = TryCast(sender, NTabStrip)
Debug.WriteLine("Currently selected index is: " + strip.SelectedIndex)
End Sub
|