ControlCollection.AddRichTextContentControl Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Aşırı Yüklemeler
AddRichTextContentControl(String) |
Belgedeki geçerli seçime yeni RichTextContentControl bir ekler. |
AddRichTextContentControl(ContentControl, String) |
Belgedeki yerel içerik denetimini temel alan yeni RichTextContentControl bir ekler. |
AddRichTextContentControl(Range, String) |
Belgede belirtilen aralıkta yeni RichTextContentControl bir ekler. |
AddRichTextContentControl(String)
Belgedeki geçerli seçime yeni RichTextContentControl bir ekler.
public:
Microsoft::Office::Tools::Word::RichTextContentControl ^ AddRichTextContentControl(System::String ^ name);
public Microsoft.Office.Tools.Word.RichTextContentControl AddRichTextContentControl (string name);
abstract member AddRichTextContentControl : string -> Microsoft.Office.Tools.Word.RichTextContentControl
Public Function AddRichTextContentControl (name As String) As RichTextContentControl
Parametreler
- name
- String
Yeni denetimin adı.
Döndürülenler
Belgeye RichTextContentControl eklenen.
Özel durumlar
name
veya null
uzunluğu sıfırdır.
Aynı ada sahip bir denetim zaten içindedir ControlCollection.
Örnekler
Aşağıdaki kod örneği, belgenin başına yeni RichTextContentControl bir ekler.
Bu sürüm, belge düzeyinde özelleştirme içindir. Bu kodu kullanmak için projenizdeki sınıfına ThisDocument
yapıştırın ve yönteminden yöntemini çağırın AddRichTextControlAtSelection
ThisDocument_Startup
.
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";
}
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
Bu sürüm, .NET Framework 4 veya .NET Framework 4.5'i hedefleyen bir uygulama düzeyi eklentisi içindir. Bu kodu kullanmak için projenizdeki sınıfına ThisAddIn
yapıştırın ve yönteminden yöntemini çağırın AddRichTextControlAtSelection
ThisAddIn_Startup
.
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";
}
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
Açıklamalar
Çalışma zamanında belgedeki geçerli seçime yeni RichTextContentControl bir ekleme yapmak için bu yöntemi kullanın. Daha fazla bilgi için bkz. Çalışma Zamanında Office Belgelerine Denetim Ekleme.
Şunlara uygulanır
AddRichTextContentControl(ContentControl, String)
Belgedeki yerel içerik denetimini temel alan yeni RichTextContentControl bir ekler.
public:
Microsoft::Office::Tools::Word::RichTextContentControl ^ AddRichTextContentControl(Microsoft::Office::Interop::Word::ContentControl ^ contentControl, System::String ^ name);
public Microsoft.Office.Tools.Word.RichTextContentControl AddRichTextContentControl (Microsoft.Office.Interop.Word.ContentControl contentControl, string name);
abstract member AddRichTextContentControl : Microsoft.Office.Interop.Word.ContentControl * string -> Microsoft.Office.Tools.Word.RichTextContentControl
Public Function AddRichTextContentControl (contentControl As ContentControl, name As String) As RichTextContentControl
Parametreler
- contentControl
- ContentControl
Bu ContentControl , yeni denetimin temelidir.
- name
- String
Yeni denetimin adı.
Döndürülenler
Belgeye RichTextContentControl eklenen.
Özel durumlar
contentControl
is null
.-or- name
is null
or has zero length.
Aynı ada sahip bir denetim zaten içindedir ControlCollection.
contentControl
yapı taşı galerisi değildir (diğer bir ifadeyle Microsoft.Office.Interop.Word. ContentControl.Type özelliği contentControl
Microsoft.Office.Interop.Word değerine sahip değildir. WdContentControlType.wdContentControlRichText).
Örnekler
Aşağıdaki kod örneği, belgedeki her yerel zengin metin denetimi için yeni RichTextContentControl bir oluşturur.
Bu sürüm, belge düzeyinde özelleştirme içindir. Bu kodu kullanmak için projenizdeki sınıfına ThisDocument
yapıştırın ve yönteminden yöntemini çağırın CreateRichTextControlsFromNativeControls
ThisDocument_Startup
.
private System.Collections.Generic.List
<Microsoft.Office.Tools.Word.RichTextContentControl> richTextControls;
private void CreateRichTextControlsFromNativeControls()
{
if (this.ContentControls.Count <= 0)
return;
richTextControls = new System.Collections.Generic.List
<Microsoft.Office.Tools.Word.RichTextContentControl>();
int count = 0;
foreach (Word.ContentControl nativeControl in this.ContentControls)
{
if (nativeControl.Type ==
Microsoft.Office.Interop.Word.WdContentControlType.wdContentControlRichText)
{
count++;
Microsoft.Office.Tools.Word.RichTextContentControl tempControl =
this.Controls.AddRichTextContentControl(nativeControl,
"VSTORichTextControl" + count.ToString());
richTextControls.Add(tempControl);
}
}
}
Private richTextControls As New System.Collections.Generic.List _
(Of Microsoft.Office.Tools.Word.RichTextContentControl)
Private Sub CreateRichTextControlsFromNativeControls()
If Me.ContentControls.Count <= 0 Then
Return
End If
Dim count As Integer = 0
For Each nativeControl As Word.ContentControl In Me.ContentControls
If nativeControl.Type = Word.WdContentControlType.wdContentControlRichText Then
count += 1
Dim tempControl As Microsoft.Office.Tools.Word.RichTextContentControl = _
Me.Controls.AddRichTextContentControl(nativeControl, _
"VSTORichTextContentControl" + count.ToString())
richTextControls.Add(tempControl)
End If
Next nativeControl
End Sub
Bu sürüm, .NET Framework 4 veya .NET Framework 4.5'i hedefleyen bir uygulama düzeyi eklentisi içindir. Bu kodu kullanmak için projenizdeki sınıfına ThisAddIn
yapıştırın ve yönteminden yöntemini çağırın CreateRichTextControlsFromNativeControls
ThisAddIn_Startup
.
private System.Collections.Generic.List
<Microsoft.Office.Tools.Word.RichTextContentControl> richTextControls;
private void CreateRichTextControlsFromNativeControls()
{
if (this.Application.ActiveDocument == null)
return;
Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
if (vstoDoc.ContentControls.Count <= 0)
return;
richTextControls = new System.Collections.Generic.List
<Microsoft.Office.Tools.Word.RichTextContentControl>();
int count = 0;
foreach (Word.ContentControl nativeControl in vstoDoc.ContentControls)
{
if (nativeControl.Type ==
Microsoft.Office.Interop.Word.WdContentControlType.wdContentControlRichText)
{
count++;
Microsoft.Office.Tools.Word.RichTextContentControl tempControl =
vstoDoc.Controls.AddRichTextContentControl(nativeControl,
"VSTORichTextControl" + count.ToString());
richTextControls.Add(tempControl);
}
}
}
Private richTextControls As New System.Collections.Generic.List _
(Of Microsoft.Office.Tools.Word.RichTextContentControl)
Private Sub CreateRichTextControlsFromNativeControls()
If Me.Application.ActiveDocument Is Nothing Then
Return
End If
Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
If vstoDoc.ContentControls.Count <= 0 Then
Return
End If
Dim count As Integer = 0
For Each nativeControl As Word.ContentControl In vstoDoc.ContentControls
If nativeControl.Type = Word.WdContentControlType.wdContentControlRichText Then
count += 1
Dim tempControl As Microsoft.Office.Tools.Word.RichTextContentControl = _
vstoDoc.Controls.AddRichTextContentControl(nativeControl, _
"VSTORichTextContentControl" + count.ToString())
richTextControls.Add(tempControl)
End If
Next nativeControl
End Sub
Aşağıdaki kod örneği, kullanıcının belgeye eklediği her yerel zengin metin denetimi için yeni RichTextContentControl bir oluşturur.
Bu sürüm, belge düzeyinde özelleştirme içindir. Bu kodu kullanmak için projenizdeki sınıfa ThisDocument
yapıştırın. C# için olay işleyicisini ThisDocument_RichTextContentControlAfterAdd
sınıfın olayına ContentControlAfterAddThisDocument
da eklemeniz gerekir.
void ThisDocument_RichTextContentControlAfterAdd(Word.ContentControl NewContentControl, bool InUndoRedo)
{
if (NewContentControl.Type == Word.WdContentControlType.wdContentControlRichText)
{
this.Controls.AddRichTextContentControl(NewContentControl,
"RichTextControl" + NewContentControl.ID);
}
}
Private Sub ThisDocument_RichTextContentControlAfterAdd(ByVal NewContentControl As Word.ContentControl, _
ByVal InUndoRedo As Boolean) Handles Me.ContentControlAfterAdd
If NewContentControl.Type = Word.WdContentControlType.wdContentControlRichText Then
Me.Controls.AddRichTextContentControl(NewContentControl, _
"RichTextControl" + NewContentControl.ID)
End If
End Sub
Bu sürüm, .NET Framework 4 veya .NET Framework 4.5'i hedefleyen bir uygulama düzeyi eklentisi içindir. Bu kodu kullanmak için projenizdeki sınıfa ThisAddIn
yapıştırın. Ayrıca, olay işleyicisini ActiveDocument_RichTextContentControlAfterAdd
etkin belgenin ContentControlAfterAdd olayına eklemeniz gerekir.
void ActiveDocument_RichTextContentControlAfterAdd(
Word.ContentControl NewContentControl, bool InUndoRedo)
{
Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
if (NewContentControl.Type == Word.WdContentControlType.wdContentControlRichText)
{
vstoDoc.Controls.AddRichTextContentControl(NewContentControl,
"RichTextControl" + NewContentControl.ID);
}
}
Private Sub ActiveDocument_RichTextContentControlAfterAdd( _
ByVal NewContentControl As Word.ContentControl, _
ByVal InUndoRedo As Boolean)
Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
If NewContentControl.Type = Word.WdContentControlType. _
wdContentControlRichText Then
vstoDoc.Controls.AddRichTextContentControl(NewContentControl, _
"RichTextControl" + NewContentControl.ID)
End If
End Sub
Açıklamalar
Çalışma zamanında belgede yerel içerik denetimini temel alan bir yeni RichTextContentControl eklemek için bu yöntemi kullanın. Bu, çalışma zamanında bir RichTextContentControl oluşturduğunuzda ve belgenin bir sonraki açışında aynı denetimi yeniden oluşturmak istediğinizde yararlıdır. Daha fazla bilgi için bkz. Çalışma Zamanında Office Belgelerine Denetim Ekleme.
Şunlara uygulanır
AddRichTextContentControl(Range, String)
Belgede belirtilen aralıkta yeni RichTextContentControl bir ekler.
public:
Microsoft::Office::Tools::Word::RichTextContentControl ^ AddRichTextContentControl(Microsoft::Office::Interop::Word::Range ^ range, System::String ^ name);
public Microsoft.Office.Tools.Word.RichTextContentControl AddRichTextContentControl (Microsoft.Office.Interop.Word.Range range, string name);
abstract member AddRichTextContentControl : Microsoft.Office.Interop.Word.Range * string -> Microsoft.Office.Tools.Word.RichTextContentControl
Public Function AddRichTextContentControl (range As Range, name As String) As RichTextContentControl
Parametreler
- name
- String
Yeni denetimin adı.
Döndürülenler
Belgeye RichTextContentControl eklenen.
Özel durumlar
name
veya null
uzunluğu sıfırdır.
Aynı ada sahip bir denetim zaten içindedir ControlCollection.
Örnekler
Aşağıdaki kod örneği, belgenin başına yeni RichTextContentControl bir ekler.
Bu sürüm, belge düzeyinde özelleştirme içindir. Bu kodu kullanmak için projenizdeki sınıfına ThisDocument
yapıştırın ve yönteminden yöntemini çağırın AddRichTextControlAtRange
ThisDocument_Startup
.
private Microsoft.Office.Tools.Word.RichTextContentControl richTextControl2;
private void AddRichTextControlAtRange()
{
this.Paragraphs[1].Range.InsertParagraphBefore();
richTextControl2 = this.Controls.AddRichTextContentControl(this.Paragraphs[1].Range,
"richTextControl2");
richTextControl2.PlaceholderText = "Enter your first name";
}
Dim richTextControl2 As Microsoft.Office.Tools.Word.RichTextContentControl
Private Sub AddRichTextControlAtRange()
Me.Paragraphs(1).Range.InsertParagraphBefore()
richTextControl2 = Me.Controls.AddRichTextContentControl(Me.Paragraphs(1).Range, _
"richTextControl2")
richTextControl2.PlaceholderText = "Enter your first name"
End Sub
Bu sürüm, .NET Framework 4 veya .NET Framework 4.5'i hedefleyen bir uygulama düzeyi eklentisi içindir. Bu kodu kullanmak için projenizdeki sınıfına ThisAddIn
yapıştırın ve yönteminden yöntemini çağırın AddRichTextControlAtRange
ThisAddIn_Startup
.
private Microsoft.Office.Tools.Word.RichTextContentControl richTextControl2;
private void AddRichTextControlAtRange()
{
if (this.Application.ActiveDocument == null)
return;
Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
vstoDoc.Paragraphs[1].Range.InsertParagraphBefore();
richTextControl2 = vstoDoc.Controls.AddRichTextContentControl(vstoDoc.Paragraphs[1].Range,
"richTextControl2");
richTextControl2.PlaceholderText = "Enter your first name";
}
Dim richTextControl2 As Microsoft.Office.Tools.Word.RichTextContentControl
Private Sub AddRichTextControlAtRange()
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()
richTextControl2 = vstoDoc.Controls.AddRichTextContentControl( _
vstoDoc.Paragraphs(1).Range, _
"richTextControl2")
richTextControl2.PlaceholderText = "Enter your first name"
End Sub
Açıklamalar
Çalışma zamanında belgede belirtilen bir aralıkta yeni RichTextContentControl eklemek için bu yöntemi kullanın. Daha fazla bilgi için bkz. Çalışma Zamanında Office Belgelerine Denetim Ekleme.