ConnectionStringEditor 類別

定義

提供使用者介面的基底類別,讓您在設計階段中選取和編輯連接字串 (Connection String) 屬性。

public ref class ConnectionStringEditor : System::Drawing::Design::UITypeEditor
public class ConnectionStringEditor : System.Drawing.Design.UITypeEditor
type ConnectionStringEditor = class
    inherit UITypeEditor
Public Class ConnectionStringEditor
Inherits UITypeEditor
繼承
ConnectionStringEditor
衍生

範例

下列程式碼範例示範如何將 類別的 ConnectionStringEditor 實例與自訂控制項中包含的屬性產生關聯。 在設計介面中編輯控制項屬性時,類別 ConnectionStringEditor 會提供使用者介面來選取和編輯屬性值的連接字串。

// 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;
        }
    }
}
' 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

備註

類別的 ConnectionStringEditor 實例是物件 UITypeEditor ,可在設計階段用來選取和編輯連接字串運算式,以及將運算式指派給控制項屬性。 例如,控制項在 SqlDataSource 設計階段使用 ConnectionStringEditor 類別來設定 屬性的值 ConnectionString

EditorAttribute使用 屬性將 與 屬性產生關聯 ConnectionStringEditor 。 在設計介面上編輯相關聯的屬性時,設計工具主機會呼叫 EditValue 方法。 方法 EditValue 會顯示用來建置連接字串運算式的使用者介面,並傳回使用者所選取的連接字串。 方法 GetEditStyle 表示使用者介面的顯示樣式。

建構函式

ConnectionStringEditor()

初始化 ConnectionStringEditor 類別的新執行個體。

屬性

IsDropDownResizable

取得值,表示使用者是否能夠調整下拉式編輯器的大小。

(繼承來源 UITypeEditor)

方法

EditValue(IServiceProvider, Object)

使用由 GetEditStyle() 方法指示的編輯器樣式,來編輯指定物件的值。

(繼承來源 UITypeEditor)
EditValue(ITypeDescriptorContext, IServiceProvider, Object)

使用指定的服務提供者和內容,編輯指定之物件的值。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetEditStyle()

取得 EditValue(IServiceProvider, Object) 方法所使用的編輯器樣式。

(繼承來源 UITypeEditor)
GetEditStyle(ITypeDescriptorContext)

為指定的內容傳回與連接字串編輯器關聯的編輯樣式。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetPaintValueSupported()

指出這個編輯器是否支援繪製物件值的表示。

(繼承來源 UITypeEditor)
GetPaintValueSupported(ITypeDescriptorContext)

指出指定的內容是否支援在指定的內容中繪製物件值的表示。

(繼承來源 UITypeEditor)
GetProviderName(Object)

ConnectionStringEditor 類別之提供的執行個體傳回提供者名稱。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
PaintValue(Object, Graphics, Rectangle)

將指定物件的表示值繪製到指定的畫布上。

(繼承來源 UITypeEditor)
PaintValue(PaintValueEventArgs)

使用指定的 PaintValueEventArgs 來繪製物件值的表示。

(繼承來源 UITypeEditor)
SetProviderName(Object, DesignerDataConnection)

將提供者名稱放置到 ConnectionStringEditor 類別之指定的執行個體上。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱