ContentControlStoreUpdatingEventArgs.Content 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取文本,它正保存到与内容控件绑定的自定义 XML 部件中。
public string Content { get; set; }
属性值
正保存到与内容控件绑定的自定义 XML 部件中的文本。
示例
下面的代码示例演示了和事件的事件处理程序 StoreUpdating ContentUpdating 。 此示例假定文档包含 PlainTextContentControl plainTextContentControl1 绑定到自定义 XML 部件中的元素的命名。 有关演示如何将内容控件绑定到自定义 XML 部件中的元素的代码示例,请参阅演练:将内容控件绑定到自定义 Xml 部件。
若要使用此代码,请将其粘贴到 ThisDocument 项目中的类。 对于 c #,还必须将事件处理程序附加到的 StoreUpdating 和 ContentUpdating 事件 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.");
}
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
注解
你可以将内容控件绑定到文档中嵌入的 XML 部分(也称为自定义 xml 部件)中的元素。 使用 Content 属性可在 Microsoft Office Word 更新绑定到控件的自定义 XML 部件之前更改文本。
有关详细信息,请参阅内容控件和自定义 XML 部件概述。