本文為機器翻譯文章。如需檢視英文版,請選取 [原文] 核取方塊。您也可以將滑鼠指標移到文字上,即可在快顯視窗顯示英文原文。
譯文
原文

ContentControlBase.StoreUpdating 事件

 

就在 Microsoft Office Word 更新繫結至內容控制項的自訂 XML 組件資料之前 (也就是內容控制項中的文字變更之後)。

命名空間:   Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word (於 Microsoft.Office.Tools.Word.dll)

event ContentControlStoreUpdatingEventHandler StoreUpdating

You can bind content controls to an element in a piece of XML (also named custom XML part) that is embedded in the document. For more information, see Content Controls and Custom XML Parts Overview.

The E:Microsoft.Office.Tools.Word.ContentControlBase.StoreUpdating event is raised when the text in a content control changes, and the content control is bound to an element in a custom XML part.

The following code example demonstrates event handlers for the E:Microsoft.Office.Tools.Word.ContentControlBase.StoreUpdating and E:Microsoft.Office.Tools.Word.ContentControlBase.ContentUpdating events. This example assumes that the document contains a T:Microsoft.Office.Tools.Word.PlainTextContentControl named plainTextContentControl1 that is bound to an element in a custom XML part. For a code example that demonstrates how to bind a content control to an element in a custom XML part, see Walkthrough: Binding Content Controls to Custom XML Parts.

To use this code, paste it into the ThisDocument class in your project. For C#, you must also attach the event handlers to the E:Microsoft.Office.Tools.Word.ContentControlBase.StoreUpdating and E:Microsoft.Office.Tools.Word.ContentControlBase.ContentUpdating events of plainTextContentControl1.

void plainTextContentControl1_StoreUpdating(object sender, 
    Microsoft.Office.Tools.Word.ContentControlStoreUpdatingEventArgs e)
{
    MessageBox.Show("The control was changed to the following value: \n\n" +
        e.Content + "\n\nThis value is about to be written to the node that is bound to this control.");
}

void plainTextContentControl1_ContentUpdating(object sender, 
    Microsoft.Office.Tools.Word.ContentControlContentUpdatingEventArgs e)
{
    MessageBox.Show("The node that is bound to this control was changed to the following value: \n\n" +
        e.Content + "\n\nThis value is about to be written to this control.");
}
回到頁首
顯示: