DropDownListContentControl.PlaceholderText Property (2007 System)
Gets or sets the text that is displayed in the DropDownListContentControl until the text is changed by a user action or some other operation.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)
Syntax
'Declaration
Public Property PlaceholderText As String
'Usage
Dim instance As DropDownListContentControl
Dim value As String
value = instance.PlaceholderText
instance.PlaceholderText = value
public string PlaceholderText { get; set; }
public:
property String^ PlaceholderText {
String^ get ();
void set (String^ value);
}
public function get PlaceholderText () : String
public function set PlaceholderText (value : String)
Property Value
Type: System.String
The text that is displayed in the control until the text is changed by a user action or some other operation.
Remarks
The placeholder text is displayed until a user selects an item or the control is populated with data from a data source.
To set the placeholder text to text that is in a BuildingBlock or a Range, use the SetPlaceholderText method.
Examples
The following code example adds a new DropDownListContentControl to the beginning of the document. Users can select the name of a day of the week in the control. The example sets the PlaceholderText property to a string that prompts the user to choose a day.
This version is for a document-level customization. To use this code, paste it into the ThisDocument class in your project, and call the AddDropDownListControlAtSelection method from the ThisDocument_Startup method.
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";
}
This version is for an application-level add-in. To use this code, paste it into the ThisAddIn class in your project, and call the AddDropDownListControlAtSelection method from the ThisAddIn_Startup method.
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 = Me.Application.ActiveDocument.GetVstoObject()
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 = this.Application.ActiveDocument.GetVstoObject();
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 Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
DropDownListContentControl Class
DropDownListContentControl Members
Microsoft.Office.Tools.Word Namespace
Change History
Date |
History |
Reason |
---|---|---|
July 2008 |
Added a version of the code example for an application-level add-in. |
SP1 feature change. |