ConnectionStringEditor クラス
アセンブリ: System.Design (system.design.dll 内)
構文
解説ConnectionStringEditor クラスのインスタンスは、デザイン時に接続文字列式を選択および編集し、その式をコントロール プロパティに割り当てるために使用できる UITypeEditor オブジェクトです。たとえば、SqlDataSource コントロールは、デザイン時に ConnectionStringEditor クラスを使用し、ConnectionString プロパティの値を設定します。
ConnectionStringEditor とプロパティとを関連付けるには、EditorAttribute 属性を使用します。関連付けられたプロパティをデザイン サーフェイスで編集する場合、デザイナ ホストによって EditValue メソッドが呼び出されます。EditValue メソッドは、接続文字列式を作成するためのユーザー インターフェイスを表示し、ユーザーが選択した接続文字列を返します。GetEditStyle メソッドは、ユーザー インターフェイスの表示スタイルを示します。
使用例カスタム コントロールに格納されたプロパティで ConnectionStringEditor クラスのインスタンスにアクセスする方法を次のコード例に示します。デザイン サーフェイスでコントロールのプロパティを編集する場合、ConnectionStringEditor クラスは、プロパティ値の接続文字列を選択および編集するためのユーザー インターフェイスを提供します。
' Define a custom class derived from the SqlDataSource Web control. Public Class SqlDataSourceWithBackup Inherits SqlDataSource Private _alternateConnectionString As String ' Define an alternate connection string, which could be used ' as a fallback value if the primary connection string fails. ' The EditorAttribute indicates the property can ' be edited at design-time with the ConnectionStringEditor class. <DefaultValue(""), _ EditorAttribute(GetType(System.Web.UI.Design.ConnectionStringEditor), _ GetType(System.Drawing.Design.UITypeEditor)), _ Category("Data"), _ Description("The alternate connection string.")> _ Public Property AlternateConnectionString() As String Get Return _alternateConnectionString End Get Set(ByVal value As String) _alternateConnectionString = value End Set End Property End Class
// Define a custom class derived from the SqlDataSource Web control. public class SqlDataSourceWithBackup : SqlDataSource { private string _alternateConnectionString; // Define an alternate connection string, which could be used // as a fallback value if the primary connection string fails. // The EditorAttribute indicates the property can // be edited at design-time with the ConnectionStringEditor class. [ DefaultValue(""), EditorAttribute(typeof(System.Web.UI.Design.ConnectionStringEditor), typeof(System.Drawing.Design.UITypeEditor)), Category("Data"), Description("The alternate connection string.") ] public string AlternateConnectionString { get { return _alternateConnectionString; } set { _alternateConnectionString = value; } } }
.NET Framework のセキュリティ
継承階層System.Drawing.Design.UITypeEditor
System.Web.UI.Design.ConnectionStringEditor
System.Web.UI.Design.WebControls.SqlDataSourceConnectionStringEditor
スレッド セーフ
プラットフォームWindows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照- ConnectionStringEditor クラスのページへのリンク