Button.ShapeRange Property (2007 System)
Gets a ShapeRange object that represents 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 ShapeRange As ShapeRange
'Usage
Dim instance As Button
Dim value As ShapeRange
value = instance.ShapeRange
public ShapeRange ShapeRange { get; }
public:
property ShapeRange^ ShapeRange {
ShapeRange^ get ();
}
public function get ShapeRange () : ShapeRange
Property Value
Type: ShapeRange
A 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 ShapeRange for the button, and then increases the width of this 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.