次の方法で共有


ContentControlBase.StoreUpdating イベント

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

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

構文

'宣言
Event StoreUpdating As ContentControlStoreUpdatingEventHandler
event ContentControlStoreUpdatingEventHandler StoreUpdating

解説

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

StoreUpdating イベントは、コンテンツ コントロールがカスタム XML 部分の要素にバインドされている場合に、コンテンツ コントロール内のテキストが変更されると発生します。

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

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

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

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.");
}

.NET Framework セキュリティ

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

参照

参照

ContentControlBase インターフェイス

Microsoft.Office.Tools.Word 名前空間

その他の技術情報

コンテンツ コントロール

カスタム XML 部分の概要

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