Export (0) Print
Expand All
Expand Minimize

Worksheet.Controls Property

Gets the collection of controls contained within the worksheet.

Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in microsoft.office.tools.excel.dll)

public virtual ControlCollection Controls { get; }

Property Value

A ControlCollection that contains all the controls on the worksheet.

A worksheet can act as a parent to a collection of controls. When several controls are added to a worksheet, each of the controls is a member of the ControlCollection of the worksheet.

You can add controls to the ControlCollection or remove them by using the methods available in the ControlCollection class.

The following code example uses the Controls property to add a Button to the current worksheet.

private void AddButton()
{
    Button button1 = this.Controls.AddButton(50, 50, 150, 50, "button1");
}

Show:
© 2015 Microsoft