Button.Parent Property (2007 System)
Gets the parent object for the Button.
Namespace: Microsoft.Office.Tools.Excel.Controls
Assembly: Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)
Syntax
'Declaration
Public ReadOnly Property Parent As Object
'Usage
Dim instance As Button
Dim value As Object
value = instance.Parent
public Object Parent { get; }
public:
property Object^ Parent {
Object^ get ();
}
public function get Parent () : Object
Property Value
Type: System.Object
The parent object for the Button.
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.
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 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 Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.