ContentControlBase.ContentUpdating イベント (2007 System)

更新 : 2007 年 11 月

コンテンツ コントロールがカスタム XML 部分にバインドされている場合、Microsoft Office Word がコンテンツ コントロール内のテキストを更新する直前に発生します。

名前空間 :  Microsoft.Office.Tools.Word
アセンブリ :  Microsoft.Office.Tools.Word.v9.0 (Microsoft.Office.Tools.Word.v9.0.dll 内)

構文

'宣言
Public Event ContentUpdating As EventHandler(Of ContentControlContentUpdatingEventArgs)
'使用
Dim instance As ContentControlBase
Dim handler As EventHandler(Of ContentControlContentUpdatingEventArgs)

AddHandler instance.ContentUpdating, handler
public event EventHandler<ContentControlContentUpdatingEventArgs> ContentUpdating

解説

コンテンツ コントロールを、文書に埋め込まれている XML 内の要素 (カスタム XML 部分とも呼ばれます) にバインドできます。詳細については、「コンテンツ コントロール」および「カスタム XML 部分の概要」を参照してください。

ContentUpdating イベントは、文書が開かれている状態でカスタム XML 部分のデータが変更された場合にのみ発生します。文書が開かれているときや、文書が閉じられた状態でカスタム XML 部分のデータが変更されたときには、このイベントは発生しません。

イベント処理の詳細については、「イベントの利用」を参照してください。

ContentUpdating イベントおよび StoreUpdating イベント用のイベント ハンドラのコード例を次に示します。この例では、文書に、カスタム XML 部分の要素にバインドされる plainTextContentControl1 という名前の PlainTextContentControl が含まれていることを前提としています。カスタム XML 部分の要素にコンテンツ コントロールをバインドする方法を説明するコード例については、「チュートリアル : カスタム XML 部分へのコンテンツ コントロールのバインド」を参照してください。

このコードを使用するには、プロジェクトの ThisDocument クラスにコードを貼り付けます。C# では、さらにイベント ハンドラを plainTextContentControl1 の ContentUpdating イベントおよび StoreUpdating イベントに結び付ける必要があります。

この例は、ドキュメント レベルのカスタマイズ用に作成されています。

Private Sub plainTextContentControl1_StoreUpdating(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ContentControlStoreUpdatingEventArgs) _
    Handles PlainTextContentControl1.StoreUpdating

    MessageBox.Show("The control was changed to the following value: " & vbCrLf & _
        e.Content & vbCrLf & "This value is about to be written to the node that is bound to this control.")
End Sub

Private Sub plainTextContentControl1_ContentUpdating(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ContentControlContentUpdatingEventArgs) _
    Handles PlainTextContentControl1.ContentUpdating

    MessageBox.Show("The node that is bound to this control was changed to the following value: " & vbCrLf & _
        e.Content & vbCrLf & "This value is about to be written to this control.")
End Sub
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.");
}

アクセス許可

  • 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

ContentControlBase クラス

ContentControlBase メンバ

Microsoft.Office.Tools.Word 名前空間

その他の技術情報

コンテンツ コントロール

カスタム XML 部分の概要

チュートリアル : カスタム XML 部分へのコンテンツ コントロールのバインド