DesignerOptionServiceとは? わかりやすく解説

DesignerOptionService クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

デザイナオプションの値を取得および設定するために使用する基本クラス提供します

名前空間: System.ComponentModel.Design
アセンブリ: System (system.dll 内)
構文構文

Public MustInherit Class
 DesignerOptionService
    Implements IDesignerOptionService
Dim instance As DesignerOptionService
public abstract class DesignerOptionService
 : IDesignerOptionService
public ref class DesignerOptionService abstract
 : IDesignerOptionService
public abstract class DesignerOptionService
 implements IDesignerOptionService
public abstract class DesignerOptionService
 implements IDesignerOptionService
解説解説

DesignerOptionService クラスは、オプションコレクション提供します。これらのオプションの各コレクションには、コレクションにさらにフィルタをかけることができるインデクサ用意されています。オプション コレクションは、その子オプションすべてのロールアップだけでなく、独自のオプション セット格納しますプロパティ間で名前の競合発生した場合、最も外側オプション オブジェクト優先されます。次の [ツール] の [オプション] ユーザー インターフェイス (UI) 構造は、最も外側オプション オブジェクトが持つ高い重要性について示してます。

WindowsFormsDesigner | General

service という名前の IDesignerOptionService の場合、GridSize プロパティの値を取得するには、次の呼び出し行います

' Obtains and shows the size of the standard design-mode grid square.
Dim size As Size = CType(designerOptionService.GetOptionValue("WindowsFormsDesigner\General",
 "GridSize"), Size)
// Obtains and shows the size of the standard design-mode grid square.
Size size = (Size)designerOptionService.GetOptionValue("WindowsFormsDesigner\\General",
 "GridSize");
// 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")));

GridSize別のページ移動させない限り、これで値を取得できますまた、IDesignerOptionService には探索機構が用意されていません。渡す文字列がわからない場合サービスプロパティ値を見つけることができません。

DesignerOptionService クラスは、このような問題対応しますコレクション問い合わせることができ、コレクションを展開可能なコレクションとしてマークする DesignerOptionService.DesignerOptionCollection オブジェクト定義されている型コンバータ存在します。この型コンバータ使用すると、デザイナ オプション サービス全体プロパティ ウィンドウ渡して、このサービス視覚的に検査できます

メモメモ

このクラス適用される HostProtectionAttribute 属性Resources プロパティの値は、SharedState です。HostProtectionAttribute は、デスクトップ アプリケーション (一般的にはアイコンダブルクリックコマンド入力、またはブラウザURL入力して起動するアプリケーション) には影響しません。詳細については、HostProtectionAttribute クラストピックまたは「SQL Server プログラミングホスト保護属性」を参照してください

使用例使用例

DesignerOptionServiceアクセスして標準オプション現在の値を表示するコード例次に示します

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Data
Imports System.Windows.Forms
Imports System.Windows.Forms.Design


' This control demonstrates retrieving the standard 
' designer option service values in design mode.

Public Class DesignerOptionServiceControl
   Inherits System.Windows.Forms.UserControl
   Private designerOptionSvc As DesignerOptionService
   
   
   Public Sub New()
      Me.BackColor = Color.Beige
      Me.Size = New Size(404, 135)
    End Sub
   
   
   Public Overrides Property
 Site() As System.ComponentModel.ISite
      Get
         Return MyBase.Site
      End Get
      Set
         MyBase.Site = value
         
         ' If siting component, attempt to obtain an DesignerOptionService.
         If Not (MyBase.Site
 Is Nothing) Then
            designerOptionSvc = CType(Me.GetService(GetType(DesignerOptionService)),
 DesignerOptionService)
         End If
      End Set
   End Property
    
   ' Displays control information and current DesignerOptionService
 
   ' values, if available.
   Protected Overrides Sub
 OnPaint(e As System.Windows.Forms.PaintEventArgs)
        e.Graphics.DrawString("DesignerOptionServiceControl",
 _
        New Font("Arial", 9), _
        New SolidBrush(Color.Blue), 4, 4)
      
      If Me.DesignMode Then
            e.Graphics.DrawString("Currently in design mode",
 _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 4, 18)
      Else
            e.Graphics.DrawString("Not in design mode. Cannot
 access DesignerOptionService.", _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Red), 4, 18)
      End If
      
      If Not (MyBase.Site
 Is Nothing) AndAlso Not
 (designerOptionSvc Is Nothing) Then
            e.Graphics.DrawString("DesignerOptionService provides
 access to the table of option values listed when", _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 4, 38)

            e.Graphics.DrawString("the Windows Forms Designer\General
 tab of the Tools\Options menu is selected.", _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 4, 50)

            e.Graphics.DrawString("Table of standard value names
 and current values", _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Red), 4, 76)

            ' Displays a table of the standard value names and current
 values.
            Dim ypos As Integer
 = 90

            ' Obtains and shows the size of the standard design-mode
 grid square.
            Dim pd As PropertyDescriptor
            pd = designerOptionSvc.Options.Properties("GridSize")

            e.Graphics.DrawString("GridSize", _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 4, ypos)

            e.Graphics.DrawString(pd.GetValue(Nothing).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;

            ' Obtains and shows whether the design mode surface grid
 is enabled.
            pd = designerOptionSvc.Options.Properties("ShowGrid")

            e.Graphics.DrawString("ShowGrid", _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 4, ypos)

            e.Graphics.DrawString(pd.GetValue(Nothing).ToString(),
 _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 200, ypos)

            ypos += 12

            ' Obtains and shows whether components should be aligned
 with the surface grid.
            pd = designerOptionSvc.Options.Properties("SnapToGrid")

            e.Graphics.DrawString("SnapToGrid", _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 4, ypos)

            e.Graphics.DrawString(pd.GetValue(Nothing).ToString(),
 _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 200, ypos)

            ypos += 12

            ' Obtains and shows which layout mode is selected.
            pd = designerOptionSvc.Options.Properties("LayoutMode")

            e.Graphics.DrawString("LayoutMode", _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 4, ypos)

            e.Graphics.DrawString(pd.GetValue(Nothing).ToString(),
 _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 200, ypos)

            ypos += 12

            ' Obtains and shows whether the Toolbox is automatoically
            ' populated with custom controls and components.
            pd = designerOptionSvc.Options.Properties("AutoToolboxPopulate")

            e.Graphics.DrawString("AutoToolboxPopulate",
 _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 4, ypos)

            e.Graphics.DrawString(pd.GetValue(Nothing).ToString(),
 _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 200, ypos)

            ypos += 12

            ' Obtains and shows whether the component cache is used.
            pd = designerOptionSvc.Options.Properties("UseOptimizedCodeGeneration")

            e.Graphics.DrawString("Optimized Code Generation",
 _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 4, ypos)

            e.Graphics.DrawString(pd.GetValue(Nothing).ToString(),
 _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 200, ypos)

            ypos += 12

            ' Obtains and shows whether smart tags are automatically
 opened.
            pd = designerOptionSvc.Options.Properties("ObjectBoundSmartTagAutoShow")

            e.Graphics.DrawString("Automatically Open Smart Tags",
 _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 4, ypos)

            e.Graphics.DrawString(pd.GetValue(Nothing).ToString(),
 _
            New Font("Arial", 8),
 _
            New SolidBrush(Color.Black), 200, ypos)
      End If
    End Sub
End Class
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace DesignerOptionServiceExample
{
    // This control demonstrates retrieving the standard 
    // designer option service values in design mode.
    public class DesignerOptionServiceControl
 : System.Windows.Forms.UserControl
    {        
        private DesignerOptionService designerOptionSvc;

        public DesignerOptionServiceControl()
        {
            this.BackColor = Color.Beige;
                    this.Size = new Size(404,
 135);
        }
        
        public override System.ComponentModel.ISite Site
        {
            get
            {
                return base.Site;
            }
            set
            {
                base.Site = value;

                // If siting component, attempt to obtain an DesignerOptionService.
                if( base.Site != null
 )                            
                    designerOptionSvc = (DesignerOptionService)this.GetService(typeof(DesignerOptionService));
                                   
            }
        }

        // Displays control information and current DesignerOptionService
 
        // values, if available.
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs
 e)
        {
            e.Graphics.DrawString("DesignerOptionServiceControl", 
                new Font("Arial", 9), 
                new SolidBrush(Color.Blue), 4, 4);

            if( this.DesignMode )
                e.Graphics.DrawString("Currently in design
 mode", 
                    new Font("Arial", 8), 
                    new SolidBrush(Color.Black), 4, 18);
            else
                e.Graphics.DrawString("Not in design mode.
 Cannot access DesignerOptionService.", 
                    new Font("Arial", 8), 
                    new SolidBrush(Color.Red), 4, 18);
            
            if( base.Site != null
 && designerOptionSvc != null )
            {
                e.Graphics.DrawString("DesignerOptionService provides access
 to the table of option values listed when", 
                    new Font("Arial", 8), 
                    new SolidBrush(Color.Black), 4, 38);

                e.Graphics.DrawString("the Windows Forms Designer\\General tab
 of the Tools\\Options menu is selected.", 
                    new Font("Arial", 8), 
                    new SolidBrush(Color.Black), 4, 50);     
           
                
                e.Graphics.DrawString("Table of standard value names and current
 values", 
                    new Font("Arial", 8), 
                    new SolidBrush(Color.Red), 4, 76);
                
                // Displays a table of the standard value names and
 current values.
                int ypos = 90;

                // 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;
                
                // Obtains and shows whether the design mode surface
 grid is enabled.
                pd = designerOptionSvc.Options.Properties["ShowGrid"];
                e.Graphics.DrawString("ShowGrid", 
                    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;
                
                // Obtains and shows whether components should be aligned
 with the surface grid.
                pd = designerOptionSvc.Options.Properties["SnapToGrid"];
                e.Graphics.DrawString("SnapToGrid", 
                    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;

                // Obtains and shows which layout mode is selected.
                pd = designerOptionSvc.Options.Properties["LayoutMode"];
                e.Graphics.DrawString("LayoutMode",
                    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;

                // Obtains and shows whether the Toolbox is automatoically
                // populated with custom controls and components.
                pd = designerOptionSvc.Options.Properties["AutoToolboxPopulate"];
                e.Graphics.DrawString("AutoToolboxPopulate",
                    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;

                // Obtains and shows whether the component cache is
 used.
                pd = designerOptionSvc.Options.Properties["UseOptimizedCodeGeneration"];
                e.Graphics.DrawString("Optimized Code Generation",
                    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;

                // Obtains and shows whether smart tags are automatically
 opened.
                pd = designerOptionSvc.Options.Properties["ObjectBoundSmartTagAutoShow"];
                e.Graphics.DrawString("Automatically Open Smart Tags",
                    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);
            }
        }
    }
}
継承階層継承階層
System.Object
  System.ComponentModel.Design.DesignerOptionService
     System.Windows.Forms.Design.WindowsFormsDesignerOptionService
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DesignerOptionService メンバ
System.ComponentModel.Design 名前空間
IDesignerOptionService
DesignerOptionService.DesignerOptionCollection

DesignerOptionService コンストラクタ


DesignerOptionService プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

DesignerOptionService クラス
System.ComponentModel.Design 名前空間
IDesignerOptionService
DesignerOptionService.DesignerOptionCollection

DesignerOptionService メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド CreateOptionCollection 名前を指定して新しい DesignerOptionService.DesignerOptionCollection を作成し指定した親に追加します
プロテクト メソッド Finalize  Objectガベージ コレクションにより収集される前に、その Objectリソース解放しその他のクリーンアップ操作実行できるようにします。 ( Object から継承されます。)
プロテクト メソッド MemberwiseClone  現在の Object簡易コピー作成します。 ( Object から継承されます。)
プロテクト メソッド PopulateOptionCollection DesignerOptionService.DesignerOptionCollection設定します
プロテクト メソッド ShowDialog 指定したオブジェクトオプション ダイアログ ボックス表示します
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.ComponentModel.Design.IDesignerOptionService.GetOptionValue パッケージ定義したオプションの値を取得します
インターフェイスの明示的な実装 System.ComponentModel.Design.IDesignerOptionService.SetOptionValue パッケージ定義したオプションの値を設定します
参照参照

関連項目

DesignerOptionService クラス
System.ComponentModel.Design 名前空間
IDesignerOptionService
DesignerOptionService.DesignerOptionCollection

DesignerOptionService メンバ

デザイナオプションの値を取得および設定するために使用する基本クラス提供します

DesignerOptionService データ型公開されるメンバを以下の表に示します


プロテクト コンストラクタプロテクト コンストラクタ
  名前 説明
プロテクト メソッド DesignerOptionService DesignerOptionService クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド CreateOptionCollection 名前を指定して新しい DesignerOptionService.DesignerOptionCollection を作成し指定した親に追加します
プロテクト メソッド Finalize  Objectガベージ コレクションにより収集される前に、その Objectリソース解放しその他のクリーンアップ操作実行できるようにします。 (Object から継承されます。)
プロテクト メソッド MemberwiseClone  現在の Object簡易コピー作成します。 (Object から継承されます。)
プロテクト メソッド PopulateOptionCollection DesignerOptionService.DesignerOptionCollection設定します
プロテクト メソッド ShowDialog 指定したオブジェクトオプション ダイアログ ボックス表示します
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.ComponentModel.Design.IDesignerOptionService.GetOptionValue パッケージ定義したオプションの値を取得します
インターフェイスの明示的な実装 System.ComponentModel.Design.IDesignerOptionService.SetOptionValue パッケージ定義したオプションの値を設定します
参照参照

関連項目

DesignerOptionService クラス
System.ComponentModel.Design 名前空間
IDesignerOptionService
DesignerOptionService.DesignerOptionCollection



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DesignerOptionService」の関連用語

DesignerOptionServiceのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DesignerOptionServiceのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS