MdbDataFileEditor Třída

Definice

Poskytuje uživatelské rozhraní v době návrhu pro výběr souboru databáze Microsoft Accessu.

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
Dědičnost
MdbDataFileEditor

Příklady

Následující příklad kódu ukazuje, jak přidružit instanci MdbDataFileEditor třídy s vlastností, která je obsažena v rámci vlastního ovládacího prvku. Když upravujete vlastnost ovládacího prvku na návrhové ploše, MdbDataFileEditor třída poskytuje uživatelské rozhraní pro výběr a úpravu názvu souboru databáze Aplikace Access pro hodnotu vlastnosti.

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

Poznámky

Objekt MdbDataFileEditor se v době návrhu používá k výběru a úpravě adresy URL souboru databáze Microsoft Accessu (.mdb) a následnému přiřazení adresy URL vlastnosti ovládacího prvku. AccessDataSource Například ovládací prvek používá MdbDataFileEditor třídu v době návrhu k nastavení hodnoty DataFile vlastnosti.

Pomocí atributu EditorAttribute přidružte MdbDataFileEditor vlastnost k vlastnosti. Při úpravě přidružené vlastnosti na návrhové ploše volá hostitel návrháře metodu EditValue . Metoda EditValue používá metodu BuildUrl , která následně zobrazí uživatelské rozhraní pro výběr adresy URL a pak vrátí adresu URL vybranou uživatelem. Metoda GetEditStyle označuje styl zobrazení uživatelského rozhraní.

Odvozujte třídu z objektu MdbDataFileEditor a definujte vlastní editor pro vlastnost adresy URL databáze Accessu. Například odvozená třída může přepsat metodu EditValue a pak volat metodu BuildUrl s vlastní Filter nebo Caption hodnotou.

Konstruktory

MdbDataFileEditor()

Inicializuje novou instanci MdbDataFileEditor třídy.

Vlastnosti

Caption

Získá titulek, který se zobrazí v dialogovém okně výběru.

Filter

Získá možnosti filtru adresy URL pro editor, který slouží k filtrování položek, které se zobrazí v dialogovém okně pro výběr adresy URL.

IsDropDownResizable

Získá hodnotu označující, zda by měl uživatel změnit velikost editoru rozevíracího seznamu.

(Zděděno od UITypeEditor)
Options

Získá možnosti pro tvůrce adres URL použít.

(Zděděno od UrlEditor)

Metody

EditValue(IServiceProvider, Object)

Upraví hodnotu zadaného objektu pomocí stylu editoru označeného metodou GetEditStyle() .

(Zděděno od UITypeEditor)
EditValue(ITypeDescriptorContext, IServiceProvider, Object)

Upraví hodnotu zadaného objektu pomocí stylu editoru poskytnutého metodou GetEditStyle(ITypeDescriptorContext) .

(Zděděno od UrlEditor)
Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.

(Zděděno od Object)
GetEditStyle()

Získá styl editoru používaný metodou EditValue(IServiceProvider, Object) .

(Zděděno od UITypeEditor)
GetEditStyle(ITypeDescriptorContext)

Získá styl EditValue(ITypeDescriptorContext, IServiceProvider, Object) úprav metody.

(Zděděno od UrlEditor)
GetHashCode()

Slouží jako výchozí hashovací funkce.

(Zděděno od Object)
GetPaintValueSupported()

Určuje, zda tento editor podporuje malování reprezentace hodnoty objektu.

(Zděděno od UITypeEditor)
GetPaintValueSupported(ITypeDescriptorContext)

Určuje, zda zadaný kontext podporuje znázornění hodnoty objektu v zadaném kontextu.

(Zděděno od UITypeEditor)
GetType()

Získá aktuální Type instanci.

(Zděděno od Object)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Objectsouboru .

(Zděděno od Object)
PaintValue(Object, Graphics, Rectangle)

Vykreslí reprezentaci hodnoty zadaného objektu na zadané plátno.

(Zděděno od UITypeEditor)
PaintValue(PaintValueEventArgs)

Vykreslí reprezentaci hodnoty objektu pomocí zadaného PaintValueEventArgsobjektu .

(Zděděno od UITypeEditor)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Platí pro

Viz také