共用方式為


CustomStrokes.Item 屬性 (Int32)

取得 CustomStrokes 集合內位於指定索引處的 Strokes 集合。

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

語法

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

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

參數

屬性值

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

備註

如果 index 與 CustomStrokes 集合的現有成員不相符,則會引發 System.ArgumentOutOfRangeException (英文)。如果您是基於開發目的而使用已安裝 Tablet PC SDK 的 Windows XP (非 Tablet Edition),而且 index 與 CustomStrokes 集合的現有成員不相符,則會引發 System.Runtime.InteropServices (英文)。

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

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

範例

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

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

    Catch E As System.Runtime.InteropServices.COMException
        ' For Windows XP (not Tablet Edition) with Tablet PC SDK installed for development purposes
        ' this exception is raised when the indexed collection does not exist

    Catch E As ArgumentOutOfRangeException
        ' For Windows XP Tablet Edition and Vista
        ' this exception is raised when the indexed 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(int mIndex, Ink mInk)
{
    try
    {
        Strokes S = mInk.CustomStrokes[mIndex];
        // In C#, the Item property is not available. The following won't compile:
        // Strokes S = mInk.CustomStrokes.Item[mIndex];

        // if the previous statement did not throw an exception, 
        // the indexed Strokes collection exists
        return true;
    }

    catch (System.Runtime.InteropServices.COMException)
    {
        // For Windows XP (not Tablet Edition) with Tablet PC SDK installed for development purposes
        // this exception is raised when the indexed collection does not exist
    }
    catch (ArgumentOutOfRangeException)
    {
        // For Windows XP Tablet Edition and Vista
        // this exception is raised when the indexed 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