|
1. In Solution Explorer, right-click ThisDocument.cs or ThisDocument.vb, and then click View Code.
2. Add the following code to the ThisDocument class. This code declares several objects that you will use later in this walkthrough.
[Visual Basic]
Private GroupControl1 As Microsoft.Office.Tools.Word.GroupContentControl
Private BuildingBlockControl1 As Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl
Private BuildingBlockControl2 As Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl
[C#]
private Microsoft.Office.Tools.Word.GroupContentControl groupControl1;
private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl1;
private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl2;
3. Add the following code to the ThisDocument_Startup method of the ThisDocument class. This code adds entries to the Microsoft.Office.Tools.Word.ComboBoxContentControl and Microsoft.Office.Tools.Word.DropDownListContentControl in the tables and sets the placeholder text that is displayed in each of these controls before the user edits them.
[Visual Basic]
ComboBoxContentControl1.PlaceholderText = "Choose a title, or enter your own"
ComboBoxContentControl1.DropdownListEntries.Add("Engineer", "Engineer", 0)
ComboBoxContentControl1.DropdownListEntries.Add("Designer", "Designer", 1)
ComboBoxContentControl1.DropdownListEntries.Add("Manager", "Manager", 2)
DropDownListContentControl1.PlaceholderText = _
"Choose a rating (1 lowest, 3 highest)"
DropDownListContentControl1.DropdownListEntries.Add("1", "1", 0)
DropDownListContentControl1.DropdownListEntries.Add("2", "2", 1)
DropDownListContentControl1.DropdownListEntries.Add("3", "3", 2)
[C#]
comboBoxContentControl1.PlaceholderText = "Choose a title, or enter your own";
comboBoxContentControl1.DropdownListEntries.Add("Engineer", "Engineer", 0);
comboBoxContentControl1.DropdownListEntries.Add("Designer", "Designer", 1);
comboBoxContentControl1.DropdownListEntries.Add("Manager", "Manager", 2);
dropDownListContentControl1.PlaceholderText =
"Choose a rating (1 lowest, 3 highest)";
dropDownListContentControl1.DropdownListEntries.Add("1", "1", 0);
dropDownListContentControl1.DropdownListEntries.Add("2", "2", 1);
dropDownListContentControl1.DropdownListEntries.Add("3", "3", 2); |