MdbDataFileEditor 类   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供用于选择 Microsoft Access 数据库文件的设计时用户界面。
public ref class MdbDataFileEditor : System::Web::UI::Design::UrlEditorpublic class MdbDataFileEditor : System.Web.UI.Design.UrlEditortype MdbDataFileEditor = class
    inherit UrlEditorPublic Class MdbDataFileEditor
Inherits UrlEditor- 继承
示例
下面的代码示例演示如何将 类的 MdbDataFileEditor 实例与自定义控件中包含的属性相关联。 在设计图面上编辑控件属性时, MdbDataFileEditor 类提供用户界面,用于选择和编辑属性值的 Access 数据库文件名。
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
注解
MdbDataFileEditor在设计时使用 对象来选择和编辑 Microsoft Access 数据库文件的 URL (.mdb) ,然后将该 URL 分配给控件属性。 例如, AccessDataSource 控件在设计时使用 MdbDataFileEditor 类来设置 属性的值 DataFile 。
EditorAttribute使用 特性将 与 属性相关联MdbDataFileEditor。 在设计图面上编辑关联的属性时,设计器宿主将调用 EditValue 方法。 方法 EditValue 使用 BuildUrl 方法,该方法反过来显示用于选择 URL 的用户界面,然后返回用户选择的 URL。 方法 GetEditStyle 指示用户界面的显示样式。
从 MdbDataFileEditor 派生类,为 Access 数据库 URL 属性定义自定义编辑器。 例如,派生类可以重写 EditValue 方法,然后使用自定义 Filter 或 Caption 值调用 BuildUrl 方法。
构造函数
| MdbDataFileEditor() | 初始化 MdbDataFileEditor 类的新实例。 | 
属性
| Caption | 获取要在选择对话框中显示的标题。 | 
| Filter | 获取编辑器的 URL 筛选选项,用于对 URL 选择对话框中出现的项进行筛选。 | 
| IsDropDownResizable | 获取一个值,该值指示是否应由用户调整下拉编辑器的大小。(继承自 UITypeEditor) | 
| Options | 获取 URL 生成器要使用的选项。(继承自 UrlEditor) | 
方法
| EditValue(IServiceProvider, Object) | 使用 GetEditStyle() 方法所指示的编辑器样式编辑指定对象的值。(继承自 UITypeEditor) | 
| EditValue(ITypeDescriptorContext, IServiceProvider, Object) | 使用 GetEditStyle(ITypeDescriptorContext) 方法所提供的编辑器样式编辑指定对象的值。(继承自 UrlEditor) | 
| Equals(Object) | 确定指定对象是否等于当前对象。(继承自 Object) | 
| GetEditStyle() | 获取由 EditValue(IServiceProvider, Object) 方法使用的编辑器样式。(继承自 UITypeEditor) | 
| GetEditStyle(ITypeDescriptorContext) | 获取 EditValue(ITypeDescriptorContext, IServiceProvider, Object) 方法的编辑样式。(继承自 UrlEditor) | 
| GetHashCode() | 作为默认哈希函数。(继承自 Object) | 
| GetPaintValueSupported() | 指示该编辑器是否支持绘制对象值的表示形式。(继承自 UITypeEditor) | 
| GetPaintValueSupported(ITypeDescriptorContext) | 指示指定的上下文是否支持在指定的上下文内绘制对象值的表示形式。(继承自 UITypeEditor) | 
| GetType() | 获取当前实例的 Type。(继承自 Object) | 
| MemberwiseClone() | 创建当前 Object 的浅表副本。(继承自 Object) | 
| PaintValue(Object, Graphics, Rectangle) | 将指定对象值表示形式绘制到指定的画布上。(继承自 UITypeEditor) | 
| PaintValue(PaintValueEventArgs) | 使用指定的 PaintValueEventArgs 绘制某个对象的值的表示形式。(继承自 UITypeEditor) | 
| ToString() | 返回表示当前对象的字符串。(继承自 Object) |