DesignerOptionService Class

Provides a base class for getting and setting option values for a designer.

Namespace: System.ComponentModel.Design
Assembly: System (in system.dll)

public ref class DesignerOptionService abstract : IDesignerOptionService
public abstract class DesignerOptionService implements IDesignerOptionService
public abstract class DesignerOptionService implements IDesignerOptionService
Not applicable.

The DesignerOptionService class provides a collection of options. Each of these option collections has an indexer that enables it to be further filtered. Each option collection contains its own set of options, as well as a rollup of all of its child options. In the event of a naming conflict between properties, the outermost options object takes precedence. The following Tools | Options user interface (UI) structure shows how the outermost options object takes on greater importance:

WindowsFormsDesigner | General

  • SnapToGrid

  • ShowGrid

  • GridSize

Given a IDesignerOptionService named service, to get to the value of the GridSize property, you would make the following call:

// Obtains and shows the size of the standard design-mode grid square.
System::Drawing::Size size =  *dynamic_cast<System::Drawing::Size^>(designerOptionService->GetOptionValue( "WindowsFormsDesigner\\General", "GridSize" ));

// Obtains and shows the size of the standard design-mode 
// grid square.
Size size = ((Size)(designerOptionService.GetOptionValue(
    "WindowsFormsDesigner\\General", "GridSize")));

This works, until you want to move GridSize to another page. Also, IDesignerOptionService provides no discovery mechanism. If you do not know what string to pass in, the service cannot find the property value.

The DesignerOptionService class addresses these issues. You can query collections, and there is a type converter defined on the DesignerOptionService.DesignerOptionCollection object that marks the collection as expandable. With this type converter, you can pass the entire designer option service to a property window and visually inspect the service.


The HostProtectionAttribute attribute applied to this class has the following Resources property value: SharedState. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

The following code example demonstrates accessing the DesignerOptionService to display the current values of the standard options.

No code example is currently available or this language may not be supported.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions