Aracılığıyla paylaş


ControlExtensions Class

Definition

Provides extension methods you can use to add Windows Forms controls to a Word document that has been customized by using the Office development tools in Visual Studio.

public ref class ControlExtensions abstract sealed
[System.Diagnostics.DebuggerNonUserCode]
public static class ControlExtensions
[<System.Diagnostics.DebuggerNonUserCode>]
type ControlExtensions = class
Public Module ControlExtensions
Inheritance
ControlExtensions
Attributes

Examples

The following code example uses the AddButton method to add a Button control to the first paragraph in the document, and then adds text to the button. To use this example, run it from the ThisDocument class in a document-level project.

private void WordRangeAddButton()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Controls.Button button1 =
        this.Controls.AddButton(this.Paragraphs[1].Range,
        56.25F, 17.25F, "button1");
    button1.Text = "OK";
}
Private Sub WordRangeAddButton()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim Button1 As Microsoft.Office.Tools.Word.Controls.Button _
        = Me.Controls.AddButton(Me.Paragraphs(1).Range, 56.25F, _
        17.25F, "Button1")
    Button1.Text = "OK"
End Sub 

Remarks

The ControlExtensions methods are extension methods that are available on the ControlCollection object returned by the Microsoft.Office.Tools.Word.Document.Controls property (in an application-level project) or the Microsoft.Office.Tools.Word.DocumentBase.Controls property (in a document-level project) at run time. To add a specific control to a document, use the method that includes the name of the control in the method name. For example, to add a Button, use the AddButton method.

For more information about adding controls to a document, see Adding Controls to Office Documents at Run Time. For more information about extension methods, see Extension Methods and Extension Methods.

Note

In Word add-in projects that target the .NET Framework 4, you must add a reference to the Microsoft.Office.Tools.Word.v4.0.Utilities.dll assembly before you can access the ControlExtensions methods.

Methods

AddButton(ControlCollection, Range, Single, Single, String)

Adds a new Button control to the document in the specified size and location.

AddButton(ControlCollection, Single, Single, Single, Single, String)

Adds a new Button control to the document in the specified size and location.

AddCheckBox(ControlCollection, Range, Single, Single, String)

Adds a new CheckBox control to the document in the specified size and location.

AddCheckBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new CheckBox control to the document in the specified size and location.

AddCheckedListBox(ControlCollection, Range, Single, Single, String)

Adds a new CheckedListBox control to the document in the specified size and location.

AddCheckedListBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new CheckedListBox control to the document in the specified size and location.

AddComboBox(ControlCollection, Range, Single, Single, String)

Adds a new ComboBox control to the document in the specified size and location.

AddComboBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new ComboBox control to the document in the specified size and location.

AddDataGridView(ControlCollection, Range, Single, Single, String)

Adds a new DataGridView control to the document in the specified size and location.

AddDataGridView(ControlCollection, Single, Single, Single, Single, String)

Adds a new DataGridView control to the document in the specified size and location.

AddDateTimePicker(ControlCollection, Range, Single, Single, String)

Adds a new DateTimePicker control to the document in the specified size and location.

AddDateTimePicker(ControlCollection, Single, Single, Single, Single, String)

Adds a new DateTimePicker control to the document in the specified size and location.

AddDomainUpDown(ControlCollection, Range, Single, Single, String)

Adds a new DomainUpDown control to the document in the specified size and location.

AddDomainUpDown(ControlCollection, Single, Single, Single, Single, String)

Adds a new DomainUpDown control to the document in the specified size and location.

AddHScrollBar(ControlCollection, Range, Single, Single, String)

Adds a new HScrollBar control to the document in the specified size and location.

AddHScrollBar(ControlCollection, Single, Single, Single, Single, String)

Adds a new HScrollBar control to the document in the specified size and location.

AddLabel(ControlCollection, Range, Single, Single, String)

Adds a new Label control to the document in the specified size and location.

AddLabel(ControlCollection, Single, Single, Single, Single, String)

Adds a new Label control to the document in the specified size and location.

AddLinkLabel(ControlCollection, Range, Single, Single, String)

Adds a new LinkLabel control to the document in the specified size and location.

AddLinkLabel(ControlCollection, Single, Single, Single, Single, String)

Adds a new LinkLabel control to the document in the specified size and location.

AddListBox(ControlCollection, Range, Single, Single, String)

Adds a new ListBox control to the document in the specified size and location.

AddListBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new ListBox control to the document in the specified size and location.

AddListView(ControlCollection, Range, Single, Single, String)

Adds a new ListView control to the document in the specified size and location.

AddListView(ControlCollection, Single, Single, Single, Single, String)

Adds a new ListView control to the document in the specified size and location.

AddMaskedTextBox(ControlCollection, Range, Single, Single, String)

Adds a new MaskedTextBox control to the document in the specified size and location.

AddMaskedTextBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new MaskedTextBox control to the document in the specified size and location.

AddMonthCalendar(ControlCollection, Range, Single, Single, String)

Adds a new MonthCalendar control to the document in the specified size and location.

AddMonthCalendar(ControlCollection, Single, Single, Single, Single, String)

Adds a new MonthCalendar control to the document in the specified size and location.

AddNumericUpDown(ControlCollection, Range, Single, Single, String)

Adds a new NumericUpDown control to the document in the specified size and location.

AddNumericUpDown(ControlCollection, Single, Single, Single, Single, String)

Adds a new NumericUpDown control to the document in the specified size and location.

AddPictureBox(ControlCollection, Range, Single, Single, String)

Adds a new PictureBox control to the document in the specified size and location.

AddPictureBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new PictureBox control to the document in the specified size and location.

AddProgressBar(ControlCollection, Range, Single, Single, String)

Adds a new ProgressBar control to the document in the specified size and location.

AddProgressBar(ControlCollection, Single, Single, Single, Single, String)

Adds a new ProgressBar control to the document in the specified size and location.

AddPropertyGrid(ControlCollection, Range, Single, Single, String)

Adds a new PropertyGrid control to the document in the specified size and location.

AddPropertyGrid(ControlCollection, Single, Single, Single, Single, String)

Adds a new PropertyGrid control to the document in the specified size and location.

AddRadioButton(ControlCollection, Range, Single, Single, String)

Adds a new RadioButton control to the document in the specified size and location.

AddRadioButton(ControlCollection, Single, Single, Single, Single, String)

Adds a new RadioButton control to the document in the specified size and location.

AddRichTextBox(ControlCollection, Range, Single, Single, String)

Adds a new RichTextBox control to the document in the specified size and location.

AddRichTextBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new RichTextBox control to the document in the specified size and location.

AddTextBox(ControlCollection, Range, Single, Single, String)

Adds a new TextBox control to the document in the specified size and location.

AddTextBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new TextBox control to the document in the specified size and location.

AddTrackBar(ControlCollection, Range, Single, Single, String)

Adds a new TrackBar control to the document in the specified size and location.

AddTrackBar(ControlCollection, Single, Single, Single, Single, String)

Adds a new TrackBar control to the document in the specified size and location.

AddTreeView(ControlCollection, Range, Single, Single, String)

Adds a new TreeView control to the document in the specified size and location.

AddTreeView(ControlCollection, Single, Single, Single, Single, String)

Adds a new TreeView control to the document in the specified size and location.

AddVScrollBar(ControlCollection, Range, Single, Single, String)

Adds a new VScrollBar control to the document in the specified size and location.

AddVScrollBar(ControlCollection, Single, Single, Single, Single, String)

Adds a new VScrollBar control to the document in the specified size and location.

AddWebBrowser(ControlCollection, Range, Single, Single, String)

Adds a new WebBrowser control to the document in the specified size and location.

AddWebBrowser(ControlCollection, Single, Single, Single, Single, String)

Adds a new WebBrowser control to the document in the specified size and location.

Applies to