次の方法で共有


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

更新 : 2007 年 11 月

新しい PropertyGrid コントロールを指定されたサイズおよび位置でワークシートに追加します。

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

構文

'宣言
Public Function AddPropertyGrid ( _
    left As Double, _
    top As Double, _
    width As Double, _
    height As Double, _
    name As String _
) As PropertyGrid
'使用
Dim instance As ControlCollection
Dim left As Double
Dim top As Double
Dim width As Double
Dim height As Double
Dim name As String
Dim returnValue As PropertyGrid

returnValue = instance.AddPropertyGrid(left, _
    top, width, height, name)
public PropertyGrid AddPropertyGrid(
    double left,
    double top,
    double width,
    double height,
    string name
)

パラメータ

  • left
    型 : System.Double

    コントロールの左端からワークシートの左端までの間隔 (ポイント単位)。

  • top
    型 : System.Double

    コントロールの上端からワークシートの上端までの距離 (ポイント単位)。

  • width
    型 : System.Double

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

  • height
    型 : System.Double

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

戻り値

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

ControlCollection インスタンスに追加された PropertyGrid コントロールを返します。

例外

例外 条件
ArgumentNullException

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

ControlNameAlreadyExistsException

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

解説

AddPropertyGrid メソッドを使用すると、PropertyGrid オブジェクトを ControlCollection の最後に追加できます。以前にプログラムで追加された PropertyGrid コントロールを削除するには、Remove() メソッドを使用します。

次のコード例は、PropertyGrid コントロールと Button コントロールをワークシートに追加します。次に、ボタンのプロパティを PropertyGrid に表示します。

Private Sub ExcelAddPropertyGrid()
    Dim PropertyGrid1 As Microsoft.Office.Tools. _
        Excel.Controls.PropertyGrid = Me.Controls. _
        AddPropertyGrid(0, 0, 150, 150, "PropertyGrid1")

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

    Button1.Text = "OK"
    PropertyGrid1.SelectedObject = Button1

End Sub

private void ExcelAddPropertyGrid()
{
    Microsoft.Office.Tools.Excel.Controls.PropertyGrid
         propertyGrid1 = this.Controls.AddPropertyGrid(
         0, 0, 150, 150, "propertyGrid1");

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

    propertyGrid1.SelectedObject = button1;
}

アクセス許可

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

参照

参照

ControlCollection クラス

ControlCollection メンバ

AddPropertyGrid オーバーロード

Microsoft.Office.Tools.Excel 名前空間