共用方式為


CustomStrokes.Item 屬性 (String)

取得 CustomStrokes 集合內具有所指定名稱的 Strokes 集合。

命名空間:  Microsoft.Ink
組件:  Microsoft.Ink (在 Microsoft.Ink.dll 中)

語法

'宣告
Public ReadOnly Property Item ( _
    name As String _
) As Strokes
'用途
Dim instance As CustomStrokes
Dim name As String
Dim value As Strokes

value = instance.Item(name)
public Strokes Item[
    string name
] { get; }
public:
property Strokes^ Item[String^ name] {
    Strokes^ get (String^ name);
}
/** @property */
public Strokes get_Item(
    String name
)
JScript 不支援索引屬性。

參數

屬性值

型別:Microsoft.Ink.Strokes
CustomStrokes 集合內所指定的 Strokes 集合。

備註

如果 name 與 CustomStrokes 集合的現有成員不相符,則會引發 System.ArgumentException (英文)。

ms582083.alert_note(zh-tw,VS.90).gif注意事項:

在 C# 中,請使用集合的索引子 (如下列範例所示),而不要使用集合的 Item 屬性。

範例

在這個範例中,如果 Ink 物件的 CustomStrokes 集合包含具有所指定名稱的 Strokes 集合,則方法會傳回 true。如果 Strokes 集合沒有與指定的名稱同名,則會引發例外狀況,而且方法會傳回 false。

Private Function CustomStrokesCollectionExists(ByVal mName As String, ByVal mInk As Ink) As Boolean
    Try
        Dim S As Strokes = mInk.CustomStrokes(mName)
        ' In VB, you can also access the named collections by using the Item property:
        ' Dim S As Strokes = mInk.CustomStrokes.Item(mName)
        '
        ' if the previous statement did not raise an exception, 
        ' the named Strokes collection exists
        Return True

    Catch E As ArgumentException
        ' this exception is raised when the named collection does not exist

    Catch E As Exception
        ' in case another type of exception is raised

    End Try
    Return False
End Function
private bool CustomStrokesCollectionExists(string mName, Ink mInk)
{
    try
    {
        Strokes S = mInk.CustomStrokes[mName];
        // In C#, the Item property is not available. The following won't compile:
        // Strokes S = mInk.CustomStrokes.Item[mName];

        // if the previous statement did not throw an exception, 
        // the named Strokes collection exists
        return true;
    }
    catch (ArgumentException)
    {
        // this exception is raised when the named collection does not exist
    }
    catch (Exception)
    {
        // in case another type of exception is raised
    }
    return false;
}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求

版本資訊

.NET Framework

支援版本:3.0

請參閱

參考

CustomStrokes 類別

CustomStrokes 成員

Item 多載

Microsoft.Ink 命名空間

Item

Strokes