Stroke.AddPropertyData(Guid, Object) 方法

定義

將自訂屬性加入至 Stroke 物件。

public:
 void AddPropertyData(Guid propertyDataId, System::Object ^ propertyData);
public void AddPropertyData (Guid propertyDataId, object propertyData);
member this.AddPropertyData : Guid * obj -> unit
Public Sub AddPropertyData (propertyDataId As Guid, propertyData As Object)

參數

propertyDataId
Guid

屬性的唯一識別項。

propertyData
Object

自訂屬性的值。 propertyData 必須屬於 CharByteInt16UInt16Int32UInt32Int64UInt64SingleDoubleDateTimeBooleanStringDecimal 類型或這些資料類型的陣列,但不包含不允許的 String

例外狀況

propertyData 引數不屬於 Parameters 一節中列出的其中一種允許資料型別。

範例

下列範例示範如何將自訂屬性新增至 Stroke 物件。

// Create a guid for the date/timestamp.
Guid dtGuid = new Guid("03457307-3475-3450-3035-640435034540");

DateTime now = DateTime.Now;

// Check whether the property is already saved
if (thisStroke.ContainsPropertyData(dtGuid))
{
    // Check whether the existing property matches the current date/timestamp
    DateTime oldDT = (DateTime)thisStroke.GetPropertyData(dtGuid);

    if (oldDT != now)
    {
        // Update the current date and time
        thisStroke.AddPropertyData(dtGuid, now);
    }
}
' Create a guid for the date/timestamp.
Dim dtGuid As New Guid("03457307-3475-3450-3035-640435034540")

Dim now As DateTime = DateTime.Now

' Check whether the property is already saved
If thisStroke.ContainsPropertyData(dtGuid) Then
    ' Check whether the existing property matches the current date/timestamp
    Dim oldDT As DateTime = CType(thisStroke.GetPropertyData(dtGuid), DateTime)

    If oldDT <> now Then
        ' Update the current date and time
        thisStroke.AddPropertyData(dtGuid, now)
    End If
End If

備註

如果您需要在 Stroke 中儲存額外資訊,這個方法會很有用。

適用於

另請參閱