MdbDataFileEditor Classe

Definição

Fornece uma interface do usuário em tempo de design para selecionar um arquivo de banco de dados do Microsoft Access.

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
Herança
MdbDataFileEditor

Exemplos

O exemplo de código a seguir demonstra como associar uma instância da classe a MdbDataFileEditor uma propriedade contida em um controle personalizado. Quando você edita a propriedade de controle na superfície de design, a MdbDataFileEditor classe fornece a interface do usuário para selecionar e editar um nome de arquivo de banco de dados do Access para o valor da propriedade.

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

Comentários

Um MdbDataFileEditor objeto é usado no momento do design para selecionar e editar uma URL para um arquivo de banco de dados do Microsoft Access (.mdb) e, em seguida, atribuir a URL a uma propriedade de controle. Por exemplo, o AccessDataSource controle usa a MdbDataFileEditor classe em tempo de design para definir o valor da DataFile propriedade.

Use o EditorAttribute atributo para associar a MdbDataFileEditor uma propriedade. Quando a propriedade associada é editada na superfície de design, o host do designer chama o EditValue método. O EditValue método usa o BuildUrl método, que, por sua vez, exibe uma interface do usuário para selecionar a URL e retorna a URL selecionada pelo usuário. O GetEditStyle método indica o estilo de exibição da interface do usuário.

Derivar uma classe do MdbDataFileEditor editor personalizado para uma propriedade de URL de banco de dados do Access. Por exemplo, uma classe derivada pode substituir o EditValue método e, em seguida, chamar o BuildUrl método com um valor ou Caption personalizadoFilter.

Construtores

MdbDataFileEditor()

Inicializa uma nova instância da classe MdbDataFileEditor.

Propriedades

Caption

Obtém a legenda a ser exibida na caixa de diálogo de seleção.

Filter

Obtém as opções de filtro de URL para o editor, que são usadas para filtrar os itens que aparecem na caixa de diálogo de seleção de URL.

IsDropDownResizable

Obtém um valor que indica se os editores de lista suspensa devem ser redimensionáveis pelo usuário.

(Herdado de UITypeEditor)
Options

Obtém as opções do construtor de URL a ser usado.

(Herdado de UrlEditor)

Métodos

EditValue(IServiceProvider, Object)

Edita o valor do objeto especificado usando o estilo de editor indicado pelo método GetEditStyle().

(Herdado de UITypeEditor)
EditValue(ITypeDescriptorContext, IServiceProvider, Object)

Edita o valor do objeto especificado usando o estilo de editor fornecido pelo método GetEditStyle(ITypeDescriptorContext).

(Herdado de UrlEditor)
Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.

(Herdado de Object)
GetEditStyle()

Obtém o estilo de editor usado pelo método EditValue(IServiceProvider, Object).

(Herdado de UITypeEditor)
GetEditStyle(ITypeDescriptorContext)

Obtém o estilo de edição do método EditValue(ITypeDescriptorContext, IServiceProvider, Object).

(Herdado de UrlEditor)
GetHashCode()

Serve como a função de hash padrão.

(Herdado de Object)
GetPaintValueSupported()

Indica se esse editor é compatível com pintura de uma representação do valor de um objeto.

(Herdado de UITypeEditor)
GetPaintValueSupported(ITypeDescriptorContext)

Indica se o contexto especificado é compatível com pintura de uma representação do valor de um objeto no contexto especificado.

(Herdado de UITypeEditor)
GetType()

Obtém o Type da instância atual.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do Object atual.

(Herdado de Object)
PaintValue(Object, Graphics, Rectangle)

Pinta uma representação do valor do objeto especificado na tela especificada.

(Herdado de UITypeEditor)
PaintValue(PaintValueEventArgs)

Pinta uma representação do valor de um objeto usando o PaintValueEventArgs especificado.

(Herdado de UITypeEditor)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.

(Herdado de Object)

Aplica-se a

Confira também