Condividi tramite


ControlExtensions.AddPropertyGrid Method

Definition

Overloads

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.

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

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

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

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.

Exceptions

The name or range argument is null, or the name argument has zero length.

A control with the same name is already in the ControlCollection instance.

The range that was specified is not valid.

Examples

The following code example adds a PropertyGrid control to the first paragraph and a Button control to the third paragraph. It then displays the properties of the button in the property grid. To use this example, run it from the ThisDocument class in a document-level project.

private void WordRangeAddPropertyGrid()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.InsertParagraphBefore();

    Microsoft.Office.Tools.Word.Controls.PropertyGrid
         propertyGrid1 = this.Controls.AddPropertyGrid(
         this.Paragraphs[1].Range, 150, 150, "propertyGrid1");
    
    Microsoft.Office.Tools.Word.Controls.Button button1 =
        this.Controls.AddButton(this.Paragraphs[3].Range,
        56.25F, 17.25F, "button1");
    button1.Text = "OK";

    propertyGrid1.SelectedObject = button1;
}
Private Sub WordRangeAddPropertyGrid()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.InsertParagraphBefore()

    Dim PropertyGrid1 As Microsoft.Office.Tools.Word. _
        Controls.PropertyGrid = Me.Controls.AddPropertyGrid( _
        Me.Paragraphs(1).Range, 150, 150, "PropertyGrid1")

    Dim Button1 As Microsoft.Office.Tools.Word.Controls.Button _
        = Me.Controls.AddButton(Me.Paragraphs(3).Range, 56.25F, _
        17.25F, "Button1")
    Button1.Text = "OK"

    PropertyGrid1.SelectedObject = Button1
End Sub 

Remarks

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

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

Applies to

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

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

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

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.

Exceptions

The name argument is null or has zero length.

A control with the same name is already in the ControlCollection instance.

Examples

The following code example adds a PropertyGrid control to the start of the document and a Button control beneath the PropertyGrid control. It then displays the properties of the button in the property grid. To use this example, run it from the ThisDocument class in a document-level project.

private void WordAddPropertyGrid()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    
    Microsoft.Office.Tools.Word.Controls.PropertyGrid
         propertyGrid1 = this.Controls.AddPropertyGrid(
         0, 0, 150, 150, "propertyGrid1");

    Microsoft.Office.Tools.Word.Controls.Button button1 =
        this.Controls.AddButton(0, 160, 56.25F, 17.25F, "button1");
    button1.Text = "OK";

    propertyGrid1.SelectedObject = button1;
}
Private Sub WordAddPropertyGrid()
    Me.Paragraphs(1).Range.InsertParagraphBefore()

    Dim PropertyGrid1 As Microsoft.Office.Tools.Word.Controls. _
        PropertyGrid = Me.Controls.AddPropertyGrid(0, 0, 150, _
        150, "PropertyGrid1")

    Dim Button1 As Microsoft.Office.Tools.Word.Controls. _
        Button = Me.Controls.AddButton(0, 160, 56.25F, 17.25F, _
        "Button1")
    Button1.Text = "OK"

    PropertyGrid1.SelectedObject = Button1
End Sub 

Remarks

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

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

Applies to