ControlCollection.AddDropDownListContentControl Yöntem (String)
Yeni bir ekler DropDownListContentControl belgedeki geçerli seçime.
Ad alanı: Microsoft.Office.Tools.Word
Derleme: Microsoft.Office.Tools.Word (Microsoft.Office.Tools.Word.dll içinde)
Sözdizimi
'Bildirim
Function AddDropDownListContentControl ( _
name As String _
) As DropDownListContentControl
DropDownListContentControl AddDropDownListContentControl(
string name
)
Parametreler
- name
Tür: System.String
Yeni denetimin adı.
Dönüş Değeri
Tür: Microsoft.Office.Tools.Word.DropDownListContentControl
DropDownListContentControl Belgeye eklenmiştir.
Özel Durumlar
Exception | Koşul |
---|---|
ArgumentNullException | nameolan nullnull başvuru (Visual Basic'te Nothing) veya sıfır uzunlukta. |
ControlNameAlreadyExistsException | Aynı ada sahip bir denetim zaten kullanılıyor ControlCollection. |
Notlar
Yeni bir eklemek için bu yöntemi kullanın DropDownListContentControl zamanında belgedeki geçerli seçime.Daha fazla bilgi için bkz. Office Belgelerine Çalışma Zamanında Denetim Ekleme.
Örnekler
Aşağıdaki kod örneği ekler yeni bir DropDownListContentControl belgenin başına.Örnek birkaç gün adlarını denetimde kullanıcının seçebileceği öğelerin listesini de ekler.
Belge düzeyi özelleştirmesinde sürümüdür.Bu kodu kullanmak için içine yapıştırın ThisDocument sınıfı proje ve çağrı AddDropDownListControlAtSelection yönteminden ThisDocument_Startup yöntem.
Dim dropDownListControl1 As Microsoft.Office.Tools.Word.DropDownListContentControl
Private Sub AddDropDownListControlAtSelection()
Me.Paragraphs(1).Range.InsertParagraphBefore()
Me.Paragraphs(1).Range.Select()
dropDownListControl1 = Me.Controls.AddDropDownListContentControl("dropDownListControl1")
With dropDownListControl1
.DropDownListEntries.Add("Monday", "Monday", 0)
.DropDownListEntries.Add("Tuesday", "Tuesday", 1)
.DropDownListEntries.Add("Wednesday", "Wednesday", 2)
.PlaceholderText = "Choose a day"
End With
End Sub
private Microsoft.Office.Tools.Word.DropDownListContentControl dropDownListControl1;
private void AddDropDownListControlAtSelection()
{
this.Paragraphs[1].Range.InsertParagraphBefore();
this.Paragraphs[1].Range.Select();
dropDownListControl1 = this.Controls.AddDropDownListContentControl("dropDownListControl1");
dropDownListControl1.DropDownListEntries.Add("Monday", "Monday", 0);
dropDownListControl1.DropDownListEntries.Add("Tuesday", "Tuesday", 1);
dropDownListControl1.DropDownListEntries.Add("Wednesday", "Wednesday", 2);
dropDownListControl1.PlaceholderText = "Choose a day";
}
Bir uygulama düzeyi eklentisi hedefler de için bu sürümü olan .NET Framework 4 veya .NET Framework 4.5.Bu kodu kullanmak için içine yapıştırın ThisAddIn sınıfı proje ve çağrı AddDropDownListControlAtSelection yönteminden ThisAddIn_Startup yöntem.
Dim dropDownListControl1 As Microsoft.Office.Tools.Word.DropDownListContentControl
Private Sub AddDropDownListControlAtSelection()
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()
dropDownListControl1 = vstoDoc.Controls.AddDropDownListContentControl("dropDownListControl1")
With dropDownListControl1
.DropDownListEntries.Add("Monday", "Monday", 0)
.DropDownListEntries.Add("Tuesday", "Tuesday", 1)
.DropDownListEntries.Add("Wednesday", "Wednesday", 2)
.PlaceholderText = "Choose a day"
End With
End Sub
private Microsoft.Office.Tools.Word.DropDownListContentControl dropDownListControl1;
private void AddDropDownListControlAtSelection()
{
if (this.Application.ActiveDocument == null)
return;
Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
vstoDoc.Paragraphs[1].Range.InsertParagraphBefore();
vstoDoc.Paragraphs[1].Range.Select();
dropDownListControl1 = vstoDoc.Controls.AddDropDownListContentControl("dropDownListControl1");
dropDownListControl1.DropDownListEntries.Add("Monday", "Monday", 0);
dropDownListControl1.DropDownListEntries.Add("Tuesday", "Tuesday", 1);
dropDownListControl1.DropDownListEntries.Add("Wednesday", "Wednesday", 2);
dropDownListControl1.PlaceholderText = "Choose a day";
}
.NET Framework Güvenliği
- Anında arayanlar için tam güven. Bu üye kısmen güvenilen kodla kullanılamaz. Daha fazla bilgi için bkz. Kısmen Güvenilen Koddan Kitaplıkları Kullanma.
Ayrıca bkz.
Başvuru
AddDropDownListContentControl Fazla Yük
Microsoft.Office.Tools.Word Ad Alanı