// Startup
myTable.Rows.Add(ref this.missing);
myTable.Rows.Last.Cells[1].Range.Text = "Phone:";
myTable.Rows.Last.Cells[2].Select();
PlainTextContentControl ptcc;
ptcc = this.Controls.AddPlainTextContentControl("Phone");
ptcc.Title = "Phone";
ptcc.PlaceholderText = "Enter your phone here";
ptcc.LockContentControl = true;
// Button_Click
PlainTextContentControl ptcc;
foreach (object ctrl in this.Controls)
{
ptcc = ctrl as PlainTextContentControl;
if ((ptcc != null) && (ptcc.Title == "Phone"))
{
ptcc.LockContentControl = false;
this.Controls.Remove(ptcc);
break;
}
}
The above code runs without error, but the PlainTextContentControl is not
removed. Investigated it and found that the dynamic content control is not
a member of this.Controls collection!!! How to remove it in code?

Signature
S.Y. Paul Lai
PL - 17 Apr 2007 17:39 GMT
OK, I found the answer:
ptcc.InnerObject.Delete(true);
Microsoft.Office.Tools.Word.PlainTextContentControl
doesn't provide a method to delete itself (STUPID!!!)
Need to use it's Interop class
Microsoft.Office.Interop.Word.ContentControl.Delete(bool DeleteContents)

Signature
S.Y. Paul Lai
> // Startup
> myTable.Rows.Add(ref this.missing);
[quoted text clipped - 22 lines]
> removed. Investigated it and found that the dynamic content control is not
> a member of this.Controls collection!!! How to remove it in code?