Aracılığıyla paylaş


ControlCollection.AddRichTextContentControl Yöntem (String)

Yeni bir ekler RichTextContentControl 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 AddRichTextContentControl ( _
    name As String _
) As RichTextContentControl
RichTextContentControl AddRichTextContentControl(
    string name
)

Parametreler

Dönüş Değeri

Tür: Microsoft.Office.Tools.Word.RichTextContentControl
RichTextContentControl 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 RichTextContentControl 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 RichTextContentControl 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ı AddRichTextControlAtSelection yönteminin ThisDocument_Startup yöntemi.

Dim richTextControl1 As Microsoft.Office.Tools.Word.RichTextContentControl

Private Sub AddRichTextControlAtSelection()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Select()
    richTextControl1 = Me.Controls.AddRichTextContentControl("richTextControl1")
    richTextControl1.PlaceholderText = "Enter your first name"
End Sub
private Microsoft.Office.Tools.Word.RichTextContentControl richTextControl1;

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

    richTextControl1 = this.Controls.AddRichTextContentControl("richTextControl1");
    richTextControl1.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ı AddRichTextControlAtSelection yönteminin ThisAddIn_Startup yöntemi.

Dim richTextControl1 As Microsoft.Office.Tools.Word.RichTextContentControl

Private Sub AddRichTextControlAtSelection()
    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()
    richTextControl1 = vstoDoc.Controls.AddRichTextContentControl("richTextControl1")
    richTextControl1.PlaceholderText = "Enter your first name"
End Sub
private Microsoft.Office.Tools.Word.RichTextContentControl richTextControl1;

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

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

    richTextControl1 = vstoDoc.Controls.AddRichTextContentControl("richTextControl1");
    richTextControl1.PlaceholderText = "Enter your first name";
}

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

ControlCollection Arabirim

AddRichTextContentControl 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