次の方法で共有


Button.Parent プロパティ

Button の親オブジェクトを取得します。

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

構文

'宣言
Public ReadOnly Property Parent As Object
public Object Parent { get; }

プロパティ値

型 : System.Object
Button の親オブジェクトです。

解説

Button の親オブジェクトは、Button をドキュメントと関連させるコンテナー コントロールです。Button を含む Range ではありません。

Button の親は、Object としてのみアクセスできます。

次のコード例では、Button コントロールを現在のワークシートに追加します。 このボタンの Click イベント ハンドラーは、Parent プロパティの値を表示します。

この例は、ドキュメント レベルのカスタマイズ用に作成されています。

Private Sub DisplayParent()
    Dim ParentButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(Me.Range("B2", "C3"), "ParentButton")
    ParentButton.Text = "Click to view parent"
    AddHandler ParentButton.Click, AddressOf parentButton_Click
End Sub

Private Sub ParentButton_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim ClickedButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        CType(sender, Microsoft.Office.Tools.Excel.Controls.Button)

    MsgBox("The parent is: " & ClickedButton.Parent.ToString())
End Sub
private void DisplayParent()
{
    Microsoft.Office.Tools.Excel.Controls.Button parentButton =
            this.Controls.AddButton(this.Range["B2", "C3"],
            "parentButton");
    parentButton.Text = "Click to view parent";
    parentButton.Click += new EventHandler(parentButton_Click);
}

void parentButton_Click(object sender, EventArgs e)
{
    Microsoft.Office.Tools.Excel.Controls.Button clickedButton =
        (Microsoft.Office.Tools.Excel.Controls.Button)sender;

    MessageBox.Show("The parent is: " +
        clickedButton.Parent.ToString());
}

.NET Framework セキュリティ

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

参照

関連項目

Button クラス

Microsoft.Office.Tools.Excel.Controls 名前空間