ShapeCollection.Count 屬性
取得集合中的圖形數目。
命名空間: Microsoft.VisualBasic.PowerPacks
組件: Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
語法
'宣告
Public ReadOnly Property Count As Integer
public int Count { get; }
public:
virtual property int Count {
int get () sealed;
}
abstract Count : int
override Count : int
final function get Count () : int
屬性值
型別:System.Int32
Integer 代表集合中的圖形數目。
實作
備註
Count屬性可以用來判斷如何許多圖形都是在ShapeCollection。它也可用來逐一查看集合,在For…Next陳述式。
範例
下列範例示範 Count 屬性的使用。這個範例要求您必須LineShape、 OvalShape,以及RectangleShape在表單上的控制項。
Private Sub Shapes_Click(
) Handles RectangleShape1.Click,
OvalShape1.Click, LineShape1.Click
Dim i As Integer = ShapeContainer1.Shapes.Count
MsgBox("There are " & CStr(i) & " shapes in the collection.")
End Sub
private void Shapes_Click(System.Object sender, System.EventArgs e)
{
int i = shapeContainer1.Shapes.Count;
Console.WriteLine("There are {0} shapes in the collection.", i);
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間
其他資源
Line 和 Shape 控制項簡介 (Visual Studio)
HOW TO:使用 LineShape 控制項繪製線條 (Visual Studio)
HOW TO:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)