Partager via


ControlExtensions.AddMaskedTextBox Method

Definition

Overloads

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

Adds a new MaskedTextBox 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.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Office::Tools::Word::Controls::MaskedTextBox ^ AddMaskedTextBox(Microsoft::Office::Tools::Word::ControlCollection ^ controls, float left, float top, float width, float height, System::String ^ name);
public static Microsoft.Office.Tools.Word.Controls.MaskedTextBox AddMaskedTextBox (this Microsoft.Office.Tools.Word.ControlCollection controls, float left, float top, float width, float height, string name);
static member AddMaskedTextBox : Microsoft.Office.Tools.Word.ControlCollection * single * single * single * single * string -> Microsoft.Office.Tools.Word.Controls.MaskedTextBox
<Extension()>
Public Function AddMaskedTextBox (controls As ControlCollection, left As Single, top As Single, width As Single, height As Single, name As String) As MaskedTextBox

Parameters

controls
ControlCollection

The collection to add the control to. Do not supply this parameter yourself. When you call this method on the collection returned by the Controls property (in an application-level project) or the Controls property (in a document-level project), this parameter is supplied automatically.

left
Single

The distance in points between the left edge of the control and the left edge of the document.

top
Single

The distance in points between the top edge of the control and the top edge of the document.

width
Single

The width of the control in points.

height
Single

The height of the control in points.

name
String

The name that can be used to index the control in the ControlCollection instance.

Returns

The control that was added to the document.

Examples

The following code example adds a MaskedTextBox control to the start of the document, and then sets the Mask property to 00/00/0000. To use this example, run it from the ThisDocument class in a document-level project.

private void WordAddMaskedTextBox()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Controls.MaskedTextBox
         maskedTextBox1 = this.Controls.AddMaskedTextBox(
         0, 0, 75, 15, "maskedTextBox1");
    maskedTextBox1.Mask = "00/00/0000";
}
Private Sub WordAddMaskedTextBox()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim MaskedTextBox1 As Microsoft.Office.Tools.Word. _
        Controls.MaskedTextBox = Me.Controls.AddMaskedTextBox( _
        0, 0, 75, 15, "MaskedTextBox1")
    MaskedTextBox1.Mask = "00/00/0000"
End Sub 

Remarks

This method enables you to add MaskedTextBox objects to the end of the ControlCollection.

To remove a MaskedTextBox that was added programmatically, use the Remove method.

Applies to

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

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

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Office::Tools::Word::Controls::MaskedTextBox ^ AddMaskedTextBox(Microsoft::Office::Tools::Word::ControlCollection ^ controls, Microsoft::Office::Interop::Word::Range ^ range, float width, float height, System::String ^ name);
public static Microsoft.Office.Tools.Word.Controls.MaskedTextBox AddMaskedTextBox (this Microsoft.Office.Tools.Word.ControlCollection controls, Microsoft.Office.Interop.Word.Range range, float width, float height, string name);
static member AddMaskedTextBox : Microsoft.Office.Tools.Word.ControlCollection * Microsoft.Office.Interop.Word.Range * single * single * string -> Microsoft.Office.Tools.Word.Controls.MaskedTextBox
<Extension()>
Public Function AddMaskedTextBox (controls As ControlCollection, range As Range, width As Single, height As Single, name As String) As MaskedTextBox

Parameters

controls
ControlCollection

The collection to add the control to. Do not supply this parameter yourself. When you call this method on the collection returned by the Controls property (in an application-level project) or the Controls property (in a document-level project), this parameter is supplied automatically.

range
Range

The location of the control.

width
Single

The width of the control in points.

height
Single

The height of the control in points.

name
String

The name that can be used to index the control in the ControlCollection instance.

Returns

The control that was added to the document.

Examples

The following code example adds a MaskedTextBox control to the first paragraph in the document, and then sets the Mask property to 00/00/0000. To use this example, run it from the ThisDocument class in a document-level project.

private void WordRangeAddMaskedTextBox()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Controls.MaskedTextBox
         maskedTextBox1 = this.Controls.AddMaskedTextBox(
         this.Paragraphs[1].Range, 75, 15, "maskedTextBox1");
    maskedTextBox1.Mask = "00/00/0000";
}
Private Sub WordRangeAddMaskedTextBox()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim MaskedTextBox1 As Microsoft.Office.Tools.Word. _
        Controls.MaskedTextBox = Me.Controls.AddMaskedTextBox( _
        Me.Paragraphs(1).Range, 75, 15, "MaskedTextBox1")
    MaskedTextBox1.Mask = "00/00/0000"
End Sub 

Remarks

This method enables you to add MaskedTextBox objects to the end of the ControlCollection.

To remove a MaskedTextBox that was added programmatically, use the Remove method.

Applies to