TabControl.RowCount 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得目前顯示在控制項索引標籤區域上的數目。
public:
property int RowCount { int get(); };
[System.ComponentModel.Browsable(false)]
public int RowCount { get; }
[<System.ComponentModel.Browsable(false)>]
member this.RowCount : int
Public ReadOnly Property RowCount As Integer
屬性值
目前在索引標籤區域中所顯示的列數。
- 屬性
範例
下列程式碼範例會建立具有五 TabPage 個 TabControl 物件的 。 這個範例會 RowCount 使用 屬性來取得索引標籤帶中目前的資料 tabControl1
列數目。
using namespace System::Drawing;
using namespace System::Windows::Forms;
public ref class Form1: public Form
{
public:
Form1()
{
TabControl^ tabControl1 = gcnew TabControl;
TabPage^ tabPage1 = gcnew TabPage;
TabPage^ tabPage2 = gcnew TabPage;
TabPage^ tabPage3 = gcnew TabPage;
TabPage^ tabPage4 = gcnew TabPage;
TabPage^ tabPage5 = gcnew TabPage;
Label^ label1 = gcnew Label;
// Allows multiple rows of tabs in the tabControl1 tab strip.
tabControl1->Multiline = true;
tabControl1->SizeMode = TabSizeMode::FillToRight;
tabControl1->Padding = Point(15,5);
array<Control^>^temp0 = {tabPage1,tabPage2,tabPage3,tabPage4,tabPage5};
tabControl1->Controls->AddRange( temp0 );
tabControl1->Location = Point(35,65);
tabControl1->Size = System::Drawing::Size( 220, 180 );
// Gets the number of rows currently in the tabControl1 tab strip.
// Assigns int value to the rows variable.
int rows = tabControl1->RowCount;
label1->Text = System::String::Concat( "There are ", rows, " rows of tabs in the tabControl1 tab strip." );
label1->Location = Point(35,25);
label1->Size = System::Drawing::Size( 220, 30 );
Size = System::Drawing::Size( 300, 300 );
array<Control^>^temp1 = {label1,tabControl1};
Controls->AddRange( temp1 );
}
};
int main()
{
Application::Run( gcnew Form1 );
}
using System.Drawing;
using System.Windows.Forms;
public class Form1 : Form
{
public Form1()
{
TabControl tabControl1 = new TabControl();
TabPage tabPage1 = new TabPage();
TabPage tabPage2 = new TabPage();
TabPage tabPage3 = new TabPage();
TabPage tabPage4 = new TabPage();
TabPage tabPage5 = new TabPage();
Label label1= new Label();
// Allows multiple rows of tabs in the tabControl1 tab strip.
tabControl1.Multiline = true;
tabControl1.SizeMode = TabSizeMode.FillToRight;
tabControl1.Padding = new Point(15, 5);
tabControl1.Controls.AddRange(new Control[] {
tabPage1, tabPage2, tabPage3, tabPage4, tabPage5});
tabControl1.Location = new Point(35, 65);
tabControl1.Size = new Size(220, 180);
// Gets the number of rows currently in the tabControl1 tab strip.
// Assigns int value to the rows variable.
int rows = tabControl1.RowCount;
label1.Text = "There are " + rows.ToString() +
" rows of tabs in the tabControl1 tab strip.";
label1.Location = new Point(35, 25);
label1.Size = new Size(220, 30);
Size = new Size(300, 300);
Controls.AddRange(new Control[] {label1, tabControl1});
}
static void Main()
{
Application.Run(new Form1());
}
}
Imports System.Drawing
Imports System.Windows.Forms
Public Class Form1
Inherits Form
Public Sub New()
Dim tabControl1 As New TabControl()
Dim tabPage1 As New TabPage()
Dim tabPage2 As New TabPage()
Dim tabPage3 As New TabPage()
Dim tabPage4 As New TabPage()
Dim tabPage5 As New TabPage()
Dim label1 As New Label()
' Allows multiple rows of tabs in the tabControl1 tab strip.
tabControl1.Multiline = True
tabControl1.SizeMode = TabSizeMode.FillToRight
tabControl1.Padding = New Point(15, 5)
tabControl1.Controls.AddRange(New Control() {tabPage1, tabPage2, tabPage3, tabPage4, tabPage5})
tabControl1.Location = New Point(35, 65)
tabControl1.Size = New Size(220, 180)
' Gets the number of rows currently in the tabControl1 tab strip.
' Assigns int value to the rows variable.
Dim rows As Integer = tabControl1.RowCount
label1.Text = "There are " + rows.ToString() + " rows of tabs in the tabControl1 tab strip."
label1.Location = New Point(35, 25)
label1.Size = New Size(220, 30)
Size = New Size(300, 300)
Controls.AddRange(New Control() {label1, tabControl1})
End Sub
Shared Sub Main()
Application.Run(New Form1())
End Sub
End Class
備註
RowCount當 屬性是 true
且您想要知道索引標籤佔用的資料列數目時 Multiline ,請使用 屬性。