Sdílet prostřednictvím


ControlExtensions.AddMaskedTextBox Method

Definition

Overloads

AddMaskedTextBox(ControlCollection, Double, Double, Double, Double, String)

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

AddMaskedTextBox(ControlCollection, Range, String)

Adds a new MaskedTextBox control to the worksheet at the range specified.

AddMaskedTextBox(ControlCollection, Double, Double, Double, Double, String)

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

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Office::Tools::Excel::Controls::MaskedTextBox ^ AddMaskedTextBox(Microsoft::Office::Tools::Excel::ControlCollection ^ controls, double left, double top, double width, double height, System::String ^ name);
public static Microsoft.Office.Tools.Excel.Controls.MaskedTextBox AddMaskedTextBox (this Microsoft.Office.Tools.Excel.ControlCollection controls, double left, double top, double width, double height, string name);
static member AddMaskedTextBox : Microsoft.Office.Tools.Excel.ControlCollection * double * double * double * double * string -> Microsoft.Office.Tools.Excel.Controls.MaskedTextBox
<Extension()>
Public Function AddMaskedTextBox (controls As ControlCollection, left As Double, top As Double, width As Double, height As Double, 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
Double

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

top
Double

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

width
Double

The width of the control in points.

height
Double

The height of the control in points.

name
String

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

Returns

The MaskedTextBox control that was added to the ControlCollection instance.

Examples

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

private void ExcelAddMaskedTextBox()
{

    Microsoft.Office.Tools.Excel.Controls.MaskedTextBox
         maskedTextBox1 = this.Controls.AddMaskedTextBox(
         0, 0, 75, 15, "maskedTextBox1");
    maskedTextBox1.Mask = "00/00/0000";
}
Private Sub ExcelAddMaskedTextBox()

    Dim MaskedTextBox1 As Microsoft.Office.Tools. _
        Excel.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 previously added programmatically, use the Remove method.

Applies to

AddMaskedTextBox(ControlCollection, Range, String)

Adds a new MaskedTextBox control to the worksheet at the range specified.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Office::Tools::Excel::Controls::MaskedTextBox ^ AddMaskedTextBox(Microsoft::Office::Tools::Excel::ControlCollection ^ controls, Microsoft::Office::Interop::Excel::Range ^ range, System::String ^ name);
public static Microsoft.Office.Tools.Excel.Controls.MaskedTextBox AddMaskedTextBox (this Microsoft.Office.Tools.Excel.ControlCollection controls, Microsoft.Office.Interop.Excel.Range range, string name);
static member AddMaskedTextBox : Microsoft.Office.Tools.Excel.ControlCollection * Microsoft.Office.Interop.Excel.Range * string -> Microsoft.Office.Tools.Excel.Controls.MaskedTextBox
<Extension()>
Public Function AddMaskedTextBox (controls As ControlCollection, range As Range, 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

A Range that provides the location for the control.

name
String

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

Returns

The MaskedTextBox control that was added to the ControlCollection instance.

Examples

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

private void ExcelRangeAddMaskedTextBox()
{

    Microsoft.Office.Tools.Excel.Controls.MaskedTextBox
         maskedTextBox1 = this.Controls.AddMaskedTextBox(
        this.Range["A1"], "maskedTextBox1");
    maskedTextBox1.Mask = "00/00/0000";
}
Private Sub ExcelRangeAddMaskedTextBox()

    Dim MaskedTextBox1 As Microsoft.Office.Tools. _
        Excel.Controls.MaskedTextBox = Me.Controls. _
        AddMaskedTextBox(Me.Range("A1"), "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 previously added programmatically, use the Remove method.

Applies to