Button.Parent Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the parent object for the Button.
public:
property System::Object ^ Parent { System::Object ^ get(); };
public object Parent { get; }
member this.Parent : obj
Public ReadOnly Property Parent As Object
Property Value
The parent object for the Button.
Examples
The following code example adds a Button control to the current worksheet. The Click event handler for this button displays the value of the Parent property.
This example is for a document-level customization.
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());
}
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
Remarks
The parent of a Button is a container control that connects the Button with the document, not the Range that contains the Button.
The parent of a Button can only be accessed as an Object.