次の方法で共有


ControlCollection.AddPropertyGrid メソッド (Range, Single, Single, String) (2007 System)

更新 : 2007 年 11 月

新しい PropertyGrid コントロールを、指定されたサイズと位置に基づいて文書に追加します。

名前空間 :  Microsoft.Office.Tools.Word
アセンブリ :  Microsoft.Office.Tools.Word.v9.0 (Microsoft.Office.Tools.Word.v9.0.dll 内)

構文

'宣言
Public Function AddPropertyGrid ( _
    range As Range, _
    width As Single, _
    height As Single, _
    name As String _
) As PropertyGrid
'使用
Dim instance As ControlCollection
Dim range As Range
Dim width As Single
Dim height As Single
Dim name As String
Dim returnValue As PropertyGrid

returnValue = instance.AddPropertyGrid(range, _
    width, height, name)
public PropertyGrid AddPropertyGrid(
    Range range,
    float width,
    float height,
    string name
)

パラメータ

  • width
    型 : System.Single

    コントロールの幅 (ポイント単位)。

  • height
    型 : System.Single

    コントロールの高さ (ポイント単位)。

  • name
    型 : System.String

    ControlCollection インスタンス内のコントロールにインデックスを作成するために使用できる名前。

戻り値

型 : Microsoft.Office.Tools.Word.Controls.PropertyGrid

ControlCollection インスタンスに追加された PropertyGrid コントロール。

例外

例外 条件
ArgumentNullException

name または range 引数が nullnull 参照 (Visual Basic では Nothing) であるか、または name 引数の長さが 0 である場合。

ControlNameAlreadyExistsException

同じ名前のコントロールが既に ControlCollection インスタンスに存在する場合。

InvalidRangeException

指定された範囲が無効である場合。

解説

このメソッドを使用すると、PropertyGrid オブジェクトを ControlCollection の最後に追加できます。

プログラムで追加された PropertyGrid を削除するには、Remove メソッドを使用します。

次のコード例は、PropertyGrid コントロールを最初の段落に追加して、Button コントロールを 3 番目の段落に追加します。次に、ボタンのプロパティをプロパティ グリッドに表示します。

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 

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;
}

アクセス許可

  • 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

ControlCollection クラス

ControlCollection メンバ

AddPropertyGrid オーバーロード

Microsoft.Office.Tools.Word 名前空間