Infragistics2.Win.UltraWinTabControl.v8.1
EnsureTabInView Method
See Also  Example
Infragistics.Win.UltraWinTabControl Namespace > UltraTab Class : EnsureTabInView Method

Scrolls the tab into view.

Syntax

Visual Basic (Declaration) 
Public Sub EnsureTabInView() 
C# 
public void EnsureTabInView()

Remarks

If the tab is already in view this method does nothing.

Otherwise the tab is scrolled into view but is not selected.

Example

The following sample code illustrates how to scroll tabs and access tabs through the VisibleTabs collection.

Visual BasicCopy Code
    Imports Infragistics.Win
    Imports Infragistics.Win.UltraWinTabs
    Imports Infragistics.Win.UltraWinTabControl

    Private Sub button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button7.Click

        ' Call the scroll method to cause tabs to scroll.
        ' Note: this does not change the ActiveTab or the
        ' SelectedTab even if they end up being scrolled
        ' out of view
        Me.ultraTabControl1.Scroll(ScrollType.Next)

        ' The following code will cause the tab to be scrolled
        ' completely into view. If it was already in view
        ' the method does nothing.
        Me.ultraTabControl1.VisibleTabs(2).EnsureTabInView()

        Dim sb As System.Text.StringBuilder
        Dim tab As UltraTab

        ' Loop over the 'VisibleTabs'. This collection contains
        ' the same tabs as in the 'Tabs' collection but maintains
        ' them in the order they are displayed visually. This
        ' includes tabs whose 'Visible' property is false.
        For Each tab In Me.ultraTabControl1.VisibleTabs

            sb = New System.Text.StringBuilder()

            ' Check to see if this is the first displayed tab
            If tab Is Me.ultraTabControl1.FirstDisplayedTab Then

                sb.Append("First displayed tab: ")

            End If

            ' The Key property returns the key of the tab. The Tabs
            ' collection exposes an indexer that will return the
            ' tab based on its key value. For example
            'Dim optionsTab As UltraTab = Me.ultraTabControl1.Tabs("Options")
            sb.Append("Key: ")
            sb.Append(tab.Key)

            ' The Text property returns the text that will be displayed
            ' on the tab
            sb.Append(", Text: ")
            sb.Append(tab.Text)

            ' The Index property returns the zero-based index of
            ' the tab in the Tabs collection
            sb.Append(", Index: ")
            sb.Append(tab.Index)

            ' The VisisbleIndex property returns the zero-based
            ' index of the tab in the VisibleTabs collection
            sb.Append(", VisibleIndex: ")
            sb.Append(tab.VisibleIndex)

            ' The Visible property determines if the tab is
            ' displayed or hidden.
            sb.Append(", Visible: ")
            sb.Append(tab.Visible)

            ' The Enabled property determines if the tab can
            ' be selected.
            sb.Append(", Enabled: ")
            sb.Append(tab.Enabled)

            ' The IsInView property returns true only if the tab
            ' is completely in view
            sb.Append(", IsInView: ")
            sb.Append(tab.IsInView)

            ' The IsHotTracked property returns true only if the
            ' mouse is over the tab and the control's HotTrack
            ' property is true.
            ' Note: The 'IsHotTracked' compares the tab
            ' with the tab returned from the HotTrackedTab
            ' property (tab Is this.ultraTabControl1.HotTrackedTab).
            sb.Append(", IsHotTracked: ")
            sb.Append(tab.IsHotTracked)

            ' The Selected property returns true if this is
            ' the selected tab. This property can be set but
            ' only to true. It throws an error if set to false.
            sb.Append(", is the selected tab: ")
            sb.Append(tab.Selected)

            ' The Active property returns true if this is
            ' the active tab. This property can be set but
            ' only to true. It throws an error if set to false.
            sb.Append(", is the active tab: ")
            sb.Append(tab.Active)

            ' The 'IsMultiRow' property returns true if the
            ' 'Style' property is set to a multi-row style.
            If Me.ultraTabControl1.IsMultiRow = True Then

                ' The RowNumber property returns the 1-based
                ' overall row number (including rows that are
                ' scrolled out of view).
                sb.Append(", RowNumber: ")
                sb.Append(tab.RowNumber)

            End If

            Debug.WriteLine(sb.ToString())

        Next

    End Sub

C#Copy Code
       using System.Diagnostics;
       
using Infragistics.Win;
       
using Infragistics.Win.UltraWinTabs;
       
using Infragistics.Win.UltraWinTabControl;

       
private void button7_Click(object sender, System.EventArgs e)
       {
           
// Call the scroll method to cause tabs to scroll.
           
// Note: this does not change the ActiveTab or the
           
// SelectedTab even if they end up being scrolled
           
// out of view
           
this.ultraTabControl1.Scroll( ScrollType.Next );

           
// The following code will cause the tab to be scrolled
           
// completely into view. If it was already in view
           
// the method does nothing.
           
this.ultraTabControl1.VisibleTabs[2].EnsureTabInView();

           System.Text.StringBuilder sb;

           
// Loop over the 'VisibleTabs'. This collection contains
           
// the same tabs as in the 'Tabs' collection but maintains
           
// them in the order they are displayed visually. This
           
// includes tabs whose 'Visible' property is false.
           
foreach ( UltraTab tab in this.ultraTabControl1.VisibleTabs )
           {
               sb =
new System.Text.StringBuilder();

               
// Check to see if this is the first displayed tab
               
if ( tab == this.ultraTabControl1.FirstDisplayedTab )
                   sb.Append(
"First displayed tab: ");

               
// The Key property returns the key of the tab. The Tabs
               
// collection exposes an indexer that will return the
               
// tab based on its key value. For example;
               
//UltraTab optionsTab = this.ultraTabControl1.Tabs["Options"];
               
sb.Append( "Key: " );
               sb.Append( tab.Key );
               
               
// The Text property returns the text that will be displayed
               
// on the tab
               
sb.Append( ", Text: " );
               sb.Append( tab.Text );

               
// The Index property returns the zero-based index of
               
// the tab in the Tabs collection
               
sb.Append( ", Index: " );
               sb.Append( tab.Index );
               
               
// The VisisbleIndex property returns the zero-based
               
// index of the tab in the VisibleTabs collection
               
sb.Append( ", VisibleIndex: " );
               sb.Append( tab.VisibleIndex );
               
               
// The Visible property determines if the tab is
               
// displayed or hidden.
               
sb.Append( ", Visible: " );
               sb.Append( tab.Visible );
               
               
// The Enabled property determines if the tab can
               
// be selected.
               
sb.Append( ", Enabled: " );
               sb.Append( tab.Enabled );

               
// The IsInView property returns true only if the tab
               
// is completely in view
               
sb.Append( ", IsInView: " );
               sb.Append( tab.IsInView );

               
// The IsHotTracked property returns true only if the
               
// mouse is over the tab and the control's HotTrack
               
// property is true.
               
// Note: The 'IsHotTracked' compares the tab
               
// with the tab returned from the HotTrackedTab
               
// property (tab == this.ultraTabControl1.HotTrackedTab).
               
sb.Append( ", IsHotTracked: " );
               sb.Append( tab.IsHotTracked );

               
// The Selected property returns true if this is
               
// the selected tab. This property can be set but
               
// only to true. It throws an error if set to false.
               
sb.Append( ", is the selected tab: " );
               sb.Append( tab.Selected );

               
// The Active property returns true if this is
               
// the active tab. This property can be set but
               
// only to true. It throws an error if set to false.
               
sb.Append( ", is the active tab: " );
               sb.Append( tab.Active );

               
// The 'IsMultiRow' property returns true if the
               
// 'Style' property is set to a multi-row style.
               
if ( this.ultraTabControl1.IsMultiRow )
               {
                   
// The RowNumber property returns the 1-based
                   
// overall row number (including rows that are
                   
// scrolled out of view).
                   
sb.Append( ", RowNumber: " );
                   sb.Append( tab.RowNumber );
               }

               Debug.WriteLine(sb.ToString());
           }
       }

See Also