Button.ShapeRange Property
Gets a Microsoft.Office.Interop.Excel.ShapeRange object that represents the Button.
Namespace: Microsoft.Office.Tools.Excel.Controls
Assembly: Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)
Syntax
'Declaration
Public ReadOnly Property ShapeRange As ShapeRange
Get
public ShapeRange ShapeRange { get; }
Property Value
Type: Microsoft.Office.Interop.Excel.ShapeRange
A Microsoft.Office.Interop.Excel.ShapeRange object that represents the Button.
Examples
The following code example adds a Button control to the current worksheet. The Click event handler for this button uses the ShapeRange property to get a Microsoft.Office.Interop.Excel.ShapeRange for the button, and then increases the width of this Microsoft.Office.Interop.Excel.ShapeRange by 10 points. Although the event handler only adjusts the width of the button, the height also changes automatically so that the control retains the original proportion.
This example is for a document-level customization.
Private Sub UseShapeRange()
Dim GrowingButton As Microsoft.Office.Tools.Excel.Controls.Button = _
Me.Controls.AddButton(Me.Range("B2", "C3"), "GrowingButton")
GrowingButton.Text = "Click to grow button"
AddHandler GrowingButton.Click, AddressOf GrowingButton_Click
End Sub
Private Sub GrowingButton_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)
ClickedButton.ShapeRange.Width += 10
End Sub
private void UseShapeRange()
{
Microsoft.Office.Tools.Excel.Controls.Button growingButton =
this.Controls.AddButton(this.Range["B2", "C3"],
"growingButton");
growingButton.Text = "Click to grow button";
growingButton.Click +=
new EventHandler(growingButton_Click);
}
void growingButton_Click(object sender, EventArgs e)
{
Microsoft.Office.Tools.Excel.Controls.Button clickedButton =
(Microsoft.Office.Tools.Excel.Controls.Button)sender;
clickedButton.ShapeRange.Width += 10;
}
.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.