Aracılığıyla paylaş


ControlCollection.AddPlainTextContentControl Yöntem (String)

Yeni bir ekler PlainTextContentControl adresindeki belgeyi geçerli seçimdeki.

Ad alanı:  Microsoft.Office.Tools.Word
Derleme:  Microsoft.Office.Tools.Word (Microsoft.Office.Tools.Word.dll içinde)

Sözdizimi

'Bildirim
Function AddPlainTextContentControl ( _
    name As String _
) As PlainTextContentControl
PlainTextContentControl AddPlainTextContentControl(
    string name
)

Parametreler

Dönüş Değeri

Tür: Microsoft.Office.Tools.Word.PlainTextContentControl
PlainTextContentControl Belgeye eklenmiştir.

Özel Durumlar

Exception Koşul
ArgumentNullException

nameise nullnull başvuru (Visual Basic'te Nothing) veya sıfır uzunlukta.

ControlNameAlreadyExistsException

Aynı ada sahip bir denetim içinde ControlCollection.

Notlar

Yeni eklemek için bu yöntemi kullanın PlainTextContentControl belgesindeki geçerli seçimi zamanında at.Daha fazla bilgi için bkz. Belgeye Çalışma Zamanında Denetim Ekleme.

Örnekler

Aşağıdaki kod örneği, yeni bir ekler PlainTextContentControl belgenin başına.

Belge düzeyinde özelleştirme için değildir.Bu kodu kullanmak için içine yapıştırın ThisDocument sınıfı proje ve çağrı AddTextControlAtSelection yönteminin ThisDocument_Startup yöntemi.

Dim plainTextControl1 As Microsoft.Office.Tools.Word.PlainTextContentControl

Private Sub AddPlainTextControlAtSelection()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Select()
    plainTextControl1 = Me.Controls.AddPlainTextContentControl("plainTextControl1")
    plainTextControl1.PlaceholderText = "Enter your first name"
End Sub
private Microsoft.Office.Tools.Word.PlainTextContentControl textControl1;

private void AddTextControlAtSelection()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.Select();

    textControl1 = this.Controls.AddPlainTextContentControl("textControl1");
    textControl1.PlaceholderText = "Enter your first name";
}

Bir uygulama düzeyinde hedefleyen eklentisi için değil .NET Framework 4.Bu kodu kullanmak için içine yapıştırın ThisAddIn sınıfı proje ve çağrı AddTextControlAtSelection yönteminin ThisAddIn_Startup yöntemi.

Dim plainTextControl1 As Microsoft.Office.Tools.Word.PlainTextContentControl

Private Sub AddPlainTextControlAtSelection()
    If Me.Application.ActiveDocument Is Nothing Then
        Return
    End If

    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    vstoDoc.Paragraphs(1).Range.InsertParagraphBefore()
    vstoDoc.Paragraphs(1).Range.Select()
    plainTextControl1 = vstoDoc.Controls.AddPlainTextContentControl("plainTextControl1")
    plainTextControl1.PlaceholderText = "Enter your first name"
End Sub
private Microsoft.Office.Tools.Word.PlainTextContentControl textControl1;

private void AddTextControlAtSelection()
{
    if (this.Application.ActiveDocument == null)
        return;

    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.Paragraphs[1].Range.InsertParagraphBefore();
    vstoDoc.Paragraphs[1].Range.Select();

    textControl1 = vstoDoc.Controls.AddPlainTextContentControl("textControl1");
    textControl1.PlaceholderText = "Enter your first name";
}

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

ControlCollection Arabirim

AddPlainTextContentControl Fazla Yük

Microsoft.Office.Tools.Word Ad Alanı

Diğer Kaynaklar

Belgeye Çalışma Zamanında Denetim Ekleme

Nasıl yapılır: Word belgeleri için içerik denetimleri ekleme