ContentControlStoreUpdatingEventArgs 接口

提供内容控件的 StoreUpdating 事件的数据。

命名空间:  Microsoft.Office.Tools.Word
程序集:  Microsoft.Office.Tools.Word(在 Microsoft.Office.Tools.Word.dll 中)

语法

声明
<GuidAttribute("5d9c73b6-b14d-43a0-99eb-6ea91fbd8456")> _
Public Interface ContentControlStoreUpdatingEventArgs
[GuidAttribute("5d9c73b6-b14d-43a0-99eb-6ea91fbd8456")]
public interface ContentControlStoreUpdatingEventArgs

ContentControlStoreUpdatingEventArgs 类型公开以下成员。

属性

  名称 说明
公共属性 Content 获取正在保存至绑定到内容控件的自定义 XML 部件中的文本。

页首

示例

下面的代码示例演示 StoreUpdatingContentUpdating 事件的事件处理程序。 此示例假定文档中包含一个名为 plainTextContentControl1 的 PlainTextContentControl,且该控件绑定到某个自定义 XML 部件中的元素。 有关演示如何将内容控件绑定到自定义 XML 部件中的元素的代码示例,请参见演练:将内容控件绑定到自定义 XML 部件

若要使用此代码,请将其粘贴到项目内的 ThisDocument 类中。 对于 C#,还必须将这两个事件处理程序附加到 plainTextContentControl1 的 StoreUpdatingContentUpdating 事件。

此示例针对的是文档级自定义项。

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

请参见

参考

Microsoft.Office.Tools.Word 命名空间

其他资源

内容控件

自定义 XML 部件概述

演练:将内容控件绑定到自定义 XML 部件