ContentControlContentUpdatingEventArgs.Content Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the text that is being written to the content control from the custom XML part that is bound to the control.
public:
property System::String ^ Content { System::String ^ get(); void set(System::String ^ value); };
public string Content { get; set; }
member this.Content : string with get, set
Public Property Content As String
Property Value
The text that is being written to the content control from the custom XML part that is bound to the control.
Examples
The following code example demonstrates event handlers for the ContentUpdating and StoreUpdating events. This example assumes that the document contains a 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 ContentUpdating and StoreUpdating events of plainTextContentControl1
.
This example is for a document-level customization. You can modify it to run in an application-level add-in. For more information, see Extending Word Documents and Excel Workbooks in VSTO Add-ins at Run Time.
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
Remarks
You can bind content controls to an element in a piece of XML (also named custom XML part) that is embedded in the document. Use the Content property to change the text before Microsoft Office Word updates the control.
For more information, see Content Controls and Custom XML Parts Overview.