ConnectionStringEditor 類別

定義

提供使用者介面的基底類別,讓您在設計階段中選取和編輯連接字串 (Connection String) 屬性。Provides a base class for a user interface to select and edit a connection string property at design time.

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 與包含在自訂控制項內的屬性產生關聯。The following code example demonstrates how to associate an instance of the ConnectionStringEditor class with a property that is contained within a custom control. 在設計介面中編輯控制項屬性時, ConnectionStringEditor 類別會提供使用者介面,以選取和編輯屬性值的連接字串。When the control property is edited in the design surface, the ConnectionStringEditor class provides the user interface to select and edit a connection string for the property value.

// 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

備註

類別的實例 ConnectionStringEditorUITypeEditor 物件,可在設計階段用來選取和編輯連接字串運算式,並將運算式指派給控制項屬性。An instance of the ConnectionStringEditor class is a UITypeEditor object that can be used at design time to select and edit a connection string expression and to assign the expression to a control property. 例如, SqlDataSource 控制項會 ConnectionStringEditor 在設計階段使用類別來設定屬性的值 ConnectionStringFor example, the SqlDataSource control uses the ConnectionStringEditor class at design time to set the value of the ConnectionString property.

使用 EditorAttribute 屬性,將 ConnectionStringEditor 與屬性產生關聯。Use the EditorAttribute attribute to associate the ConnectionStringEditor with a property. 在設計介面上編輯相關聯的屬性時,設計工具主機會呼叫 EditValue 方法。When the associated property is edited on the design surface, the designer host calls the EditValue method. EditValue方法會顯示用來建立連接字串運算式的使用者介面,並傳回使用者所選取的連接字串。The EditValue method displays a user interface for building the connection string expression and returns the connection string that is selected by the user. GetEditStyle方法表示使用者介面的顯示樣式。The GetEditStyle method indicates the display style of the user interface.

建構函式

ConnectionStringEditor()

初始化 ConnectionStringEditor 類別的新執行個體。Initializes a new instance of the ConnectionStringEditor class.

屬性

IsDropDownResizable

取得值,表示使用者是否能夠調整下拉式編輯器的大小。Gets a value indicating whether drop-down editors should be resizable by the user.

(繼承來源 UITypeEditor)

方法

EditValue(IServiceProvider, Object)

使用由 GetEditStyle() 方法指示的編輯器樣式,來編輯指定物件的值。Edits the value of the specified object using the editor style indicated by the GetEditStyle() method.

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

使用指定的服務提供者和內容,編輯指定之物件的值。Edits the value of the specified object by using the specified service provider and context.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetEditStyle()

取得 EditValue(IServiceProvider, Object) 方法所使用的編輯器樣式。Gets the editor style used by the EditValue(IServiceProvider, Object) method.

(繼承來源 UITypeEditor)
GetEditStyle(ITypeDescriptorContext)

為指定的內容傳回與連接字串編輯器關聯的編輯樣式。Returns the editing style that is associated with the connection string editor for the specified context.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetPaintValueSupported()

指出這個編輯器是否支援繪製物件值的表示。Indicates whether this editor supports painting a representation of an object's value.

(繼承來源 UITypeEditor)
GetPaintValueSupported(ITypeDescriptorContext)

指出指定的內容是否支援在指定的內容中繪製物件值的表示。Indicates whether the specified context supports painting a representation of an object's value within the specified context.

(繼承來源 UITypeEditor)
GetProviderName(Object)

ConnectionStringEditor 類別之提供的執行個體傳回提供者名稱。Returns the provider name for the provided instance of the ConnectionStringEditor class.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

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

將指定物件的表示值繪製到指定的畫布上。Paints a representation of the value of the specified object to the specified canvas.

(繼承來源 UITypeEditor)
PaintValue(PaintValueEventArgs)

使用指定的 PaintValueEventArgs 來繪製物件值的表示。Paints a representation of the value of an object using the specified PaintValueEventArgs.

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

將提供者名稱放置到 ConnectionStringEditor 類別之指定的執行個體上。Puts the provider name on the specified instance of the ConnectionStringEditor class.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於

另請參閱