Stroke.AddPropertyData(Guid, Object) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
為物件新增自訂屬性 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必須是 型別 Char、 Byte、 Int16UInt16Int32UInt32Int64UInt64SingleDoubleDateTimeBooleanStringDecimal,或是這些資料型態的陣列,但 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,這種方法非常有用。