Export (0) Print
Expand All

DesignerOptionService.Options Property

Gets the options collection for this service.

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

public DesignerOptionService.DesignerOptionCollection Options { get; }

There is always a global options collection that contains child collections.

The following code example shows how you can navigate the collections by named indexers so you can get the value of the GridSize option. All three variations return the same value.

// Obtains and shows the size of the standard design-mode grid square.
PropertyDescriptor pd;
pd = designerOptionSvc.Options.Properties["GridSize"];
e.Graphics.DrawString("GridSize", 
    new Font("Arial", 8), 
    new SolidBrush(Color.Black), 4, ypos);
e.Graphics.DrawString(pd.GetValue(null).ToString(), 
    new Font("Arial", 8), 
    new SolidBrush(Color.Black), 200, ypos);
ypos += 12;

// Uncomment the following code to demonstrate that this 
// alternate syntax works the same as the previous syntax. 

//pd = designerOptionSvc.Options["WindowsFormsDesigner"].Properties["GridSize"];
//e.Graphics.DrawString("GridSize",
//    new Font("Arial", 8),
//    new SolidBrush(Color.Black), 4, ypos); 
//e.Graphics.DrawString(pd.GetValue(null).ToString(), 
//    new Font("Arial", 8),
//    new SolidBrush(Color.Black), 200, ypos); 
//ypos += 12; 

//pd = designerOptionSvc.Options["WindowsFormsDesigner"]["General"].Properties["GridSize"];
//e.Graphics.DrawString("GridSize",
//    new Font("Arial", 8),
//    new SolidBrush(Color.Black), 4, ypos); 
//e.Graphics.DrawString(pd.GetValue(null).ToString(), 
//    new Font("Arial", 8),
//    new SolidBrush(Color.Black), 200, ypos); 
//ypos += 12;

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft