MdbDataFileEditor 类

定义

提供用于选择 Microsoft Access 数据库文件的设计时用户界面。Provides a design-time user interface for selecting a Microsoft Access database file.

public ref class MdbDataFileEditor : System::Web::UI::Design::UrlEditor
public class MdbDataFileEditor : System.Web.UI.Design.UrlEditor
type MdbDataFileEditor = class
    inherit UrlEditor
Public Class MdbDataFileEditor
Inherits UrlEditor
继承
MdbDataFileEditor

示例

下面的代码示例演示如何将MdbDataFileEditor类的实例与自定义控件内包含的属性相关联。The following code example demonstrates how to associate an instance of the MdbDataFileEditor class with a property that is contained within a custom control. 在设计图面上编辑控件属性时, MdbDataFileEditor类提供用户界面, 以便为属性值选择和编辑 Access 数据库文件名。When you edit the control property on the design surface, the MdbDataFileEditor class provides the user interface to select and edit an Access database file name for the property value.

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.Design.WebControls;
using System.Web.UI.WebControls;
using System.IO;

namespace ControlDesignerSamples.CS
{
    // Define a simple text control, derived from the 
    // System.Web.UI.WebControls.Label class.
    [
        Designer(typeof(TextControlDesigner))
    ]
    public class SimpleTextControl : Label
    {
        // Define a private member to store the file name value in the control.
        private string _filename = "";
        private string _internalText = "";

        // Define the public MDB data file name property.  Indicate that the
        // property can be edited at design-time with the MdbDataFileEditor class.
        [EditorAttribute(typeof(System.Web.UI.Design.MdbDataFileEditor), 
                         typeof(System.Drawing.Design.UITypeEditor))]
        public string MdbFileName
        {
            get
            {
                return _filename;
            }
            set
            {
                _filename = value;
            }
        }

        // Define a property that returns the timestamp
        // for the selected file.
        public string LastChanged
        {
            get
            {
                if ((_filename != null) && (_filename.Length > 0))
                {
                    if (File.Exists(_filename))
                    {
                        DateTime lastChangedStamp = File.GetLastWriteTime(_filename);
                        return lastChangedStamp.ToLongDateString();
                    }
                }
                return "";
            }
        }

        // Override the control Text property, setting the default
        // text to the LastChanged string value for the selected
        // file name.  If the file name has not been set in the
        // design view, then default to an empty string.
        public override string Text
        {
            get
            {
                if ((_internalText == "") && (LastChanged.Length > 0))
                {
                    // If the internally stored value hasn't been set,
                    // and the file name property has been set,
                    // return the last changed timestamp for the file.
                    _internalText = LastChanged;
                } 
                return _internalText;
            }

            set
            {
                if ((value != null) && (value.Length > 0))
                {
                    _internalText = value;
                }
                else {
                    _internalText = "";
                }
            }
        }
    }
}

Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls
Imports System.Web.UI.WebControls
Imports System.IO

Namespace ControlDesignerSamples.VB


    ' Define a simple text control, derived from the 
    ' System.Web.UI.WebControls.Label class.

    <Designer(GetType(TextControlDesigner))> _
    Public Class SimpleTextControl
        Inherits Label

        ' Define a private member to store the file name value in the control.
        Private _filename As String = ""
        Private _internalText As String = ""

        ' Define the public MDB data file name property.  Indicate that the
        ' property can be edited at design-time with the MdbDataFileEditor class.
        <EditorAttribute(GetType(System.Web.UI.Design.MdbDataFileEditor), _
                         GetType(System.Drawing.Design.UITypeEditor))> _
        Public Property MdbFileName() As String
            Get
                Return _filename
            End Get

            Set(ByVal value As String)
                _filename = value
            End Set
        End Property

        ' Define a property that returns the timestamp
        ' for the selected file.
        Public ReadOnly Property LastChanged() As String
            Get
                If Not _filename Is Nothing AndAlso _filename.Length > 0 Then
                    If File.Exists(_filename) Then
                        Dim lastChangedStamp As DateTime
                        lastChangedStamp = File.GetLastWriteTime(_filename)
                        Return lastChangedStamp.ToLongDateString()
                    End If
                End If

                Return String.Empty

            End Get

        End Property

        ' Override the control Text property, setting the default
        ' text to the LastChanged string value for the selected
        ' file name.  If the file name has not been set in the
        ' design view, then default to an empty string.
        Public Overrides Property Text() As String
            Get
                If _internalText.Length = 0 And LastChanged.Length > 0 Then
                    ' If the internally stored value hasn't been set,
                    ' and the file name property has been set,
                    ' return the last changed timestamp for the file.

                    _internalText = LastChanged
                End If
                Return _internalText
            End Get

            Set(ByVal value As String)
                If Not value Is Nothing AndAlso value.Length > 0 Then
                    _internalText = value
                Else
                    _internalText = String.Empty
                End If

            End Set
        End Property

    End Class
End Namespace

注解

在设计时使用对象来选择和编辑MicrosoftAccess数据库文件(.mdb)的url,然后将该url分配给控件属性。MdbDataFileEditorAn MdbDataFileEditor object is used at design time to select and edit a URL for a Microsoft Access database file (.mdb), and then assign the URL to a control property. 例如, AccessDataSource控件在设计时MdbDataFileEditor使用类来DataFile设置属性的值。For example, the AccessDataSource control uses the MdbDataFileEditor class at design time to set the value of the DataFile property.

EditorAttribute使用特性MdbDataFileEditor将与属性相关联。Use the EditorAttribute attribute to associate the MdbDataFileEditor with a property. 在设计图面上编辑关联的属性时, 设计器宿主将调用EditValue方法。When the associated property is edited on the design surface, the designer host calls the EditValue method. EditValue 方法BuildUrl使用方法, 该方法依次显示用于选择 URL 的用户界面, 然后返回用户选择的 url。The EditValue method uses the BuildUrl method, which in turn displays a user interface for selecting the URL, and then returns the URL that is selected by the user. GetEditStyle方法指示用户界面的显示样式。The GetEditStyle method indicates the display style of the user interface.

从派生类MdbDataFileEditor , 以定义 Access 数据库 URL 属性的自定义编辑器。Derive a class from the MdbDataFileEditor to define a custom editor for an Access database URL property. 例如, 派生类可以EditValue重写方法, 然后使用自定义FilterCaptionBuildUrl调用方法。For example, a derived class can override the EditValue method, and then call the BuildUrl method with a custom Filter or Caption value.

构造函数

MdbDataFileEditor()

初始化 MdbDataFileEditor 类的新实例。Initializes a new instance of the MdbDataFileEditor class.

属性

Caption

获取要在选择对话框中显示的标题。Gets the caption to display on the selection dialog box.

Filter

获取编辑器的 URL 筛选选项,用于对 URL 选择对话框中出现的项进行筛选。Gets the URL filter options for the editor, which is used to filter the items that appear in the URL selection dialog box.

IsDropDownResizable

获取一个值,该值指示是否应由用户调整下拉编辑器的大小。Gets a value indicating whether drop-down editors should be resizable by the user.

(继承自 UITypeEditor)
Options

获取 URL 生成器要使用的选项。Gets the options for the URL builder to use.

(继承自 UrlEditor)

方法

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)

使用 GetEditStyle(ITypeDescriptorContext) 方法所提供的编辑器样式编辑指定对象的值。Edits the value of the specified object using the editor style provided by the GetEditStyle(ITypeDescriptorContext) method.

(继承自 UrlEditor)
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)

获取 EditValue(ITypeDescriptorContext, IServiceProvider, Object) 方法的编辑样式。Gets the editing style of the EditValue(ITypeDescriptorContext, IServiceProvider, Object) method.

(继承自 UrlEditor)
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)
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)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅