Export (0) Print
Expand All

MdbDataFileEditor Class

Provides a design-time user interface for selecting a Microsoft Access database file.

Namespace:  System.Web.UI.Design
Assembly:  System.Design (in System.Design.dll)

[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public class MdbDataFileEditor : UrlEditor

The MdbDataFileEditor type exposes the following members.

  NameDescription
Public methodMdbDataFileEditorInitializes a new instance of the MdbDataFileEditor class.
Top

  NameDescription
Protected propertyCaptionGets the caption to display on the selection dialog box. (Overrides UrlEditor.Caption.)
Protected propertyFilterGets the URL filter options for the editor, which is used to filter the items that appear in the URL selection dialog box. (Overrides UrlEditor.Filter.)
Public propertyIsDropDownResizableGets a value indicating whether drop-down editors should be resizable by the user. (Inherited from UITypeEditor.)
Protected propertyOptionsGets the options for the URL builder to use. (Inherited from UrlEditor.)
Top

  NameDescription
Public methodEditValue(IServiceProvider, Object)Edits the value of the specified object using the editor style indicated by the GetEditStyle method. (Inherited from UITypeEditor.)
Public methodEditValue(ITypeDescriptorContext, IServiceProvider, Object)Edits the value of the specified object using the editor style provided by the GetEditStyle method. (Inherited from UrlEditor.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEditStyle()Gets the editor style used by the EditValue method. (Inherited from UITypeEditor.)
Public methodGetEditStyle(ITypeDescriptorContext)Gets the editing style of the EditValue method. (Inherited from UrlEditor.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetPaintValueSupported()Indicates whether this editor supports painting a representation of an object's value. (Inherited from UITypeEditor.)
Public methodGetPaintValueSupported(ITypeDescriptorContext)Indicates whether the specified context supports painting a representation of an object's value within the specified context. (Inherited from UITypeEditor.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodPaintValue(PaintValueEventArgs)Paints a representation of the value of an object using the specified PaintValueEventArgs. (Inherited from UITypeEditor.)
Public methodPaintValue(Object, Graphics, Rectangle)Paints a representation of the value of the specified object to the specified canvas. (Inherited from UITypeEditor.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

An 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. For example, the AccessDataSource control uses the MdbDataFileEditor class at design time to set the value of the DataFile property.

Use the EditorAttribute attribute to associate the MdbDataFileEditor with a property. When the associated property is edited on the design surface, the designer host calls the EditValue method. 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. The GetEditStyle method indicates the display style of the user interface.

Derive a class from the MdbDataFileEditor to define a custom editor for an Access database URL property. For example, a derived class can override the EditValue method, and then call the BuildUrl method with a custom Filter or Caption value.

The following code example demonstrates how to associate an instance of the MdbDataFileEditor class with a property that is contained within a custom control. 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 = "";
                }
            }
        }
    }

}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft