ConnectionStringEditor 类

定义

为用户界面提供基类,以便在设计时选择和编辑连接字符串属性。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

注解

ConnectionStringEditor 类的实例是一个 UITypeEditor 对象,可在设计时用于选择和编辑连接字符串表达式,并将该表达式分配给控件属性。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 类来设置 ConnectionString 属性的值。For 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)

适用于

另请参阅