MdbDataFileEditor Clase
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Proporciona una interfaz de usuario en tiempo de diseño para seleccionar un archivo de base de datos de 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
- Herencia
Ejemplos
En el ejemplo de código siguiente se muestra cómo asociar una instancia de la MdbDataFileEditor clase a una propiedad contenida en un control personalizado. Al editar la propiedad de control en la superficie de diseño, la MdbDataFileEditor clase proporciona la interfaz de usuario para seleccionar y editar un nombre de archivo de base de datos de Access para el valor de propiedad.
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
Comentarios
Un MdbDataFileEditor objeto se usa en tiempo de diseño para seleccionar y editar una dirección URL para un archivo de base de datos de Microsoft Access (.mdb) y, a continuación, asignar la dirección URL a una propiedad de control. Por ejemplo, el AccessDataSource control usa la MdbDataFileEditor clase en tiempo de diseño para establecer el valor de la DataFile propiedad .
Use el EditorAttribute atributo para asociar el MdbDataFileEditor objeto a una propiedad . Cuando la propiedad asociada se edita en la superficie de diseño, el host del diseñador llama al EditValue método . El EditValue método usa el BuildUrl método , que a su vez muestra una interfaz de usuario para seleccionar la dirección URL y, a continuación, devuelve la dirección URL seleccionada por el usuario. El GetEditStyle método indica el estilo de presentación de la interfaz de usuario.
Derive una clase de MdbDataFileEditor para definir un editor personalizado para una propiedad de dirección URL de base de datos de Access. Por ejemplo, una clase derivada puede invalidar el EditValue método y, a continuación, llamar al BuildUrl método con un valor o Caption personalizadoFilter.
Constructores
| Nombre | Description |
|---|---|
| MdbDataFileEditor() |
Inicializa una nueva instancia de la clase MdbDataFileEditor. |
Propiedades
| Nombre | Description |
|---|---|
| Caption |
Obtiene el título que se va a mostrar en el cuadro de diálogo de selección. |
| Filter |
Obtiene las opciones de filtro de dirección URL para el editor, que se usa para filtrar los elementos que aparecen en el cuadro de diálogo selección de dirección URL. |
| IsDropDownResizable |
Obtiene un valor que indica si el usuario debe cambiar el tamaño de los editores desplegables. (Heredado de UITypeEditor) |
| Options |
Obtiene las opciones del generador de direcciones URL que se va a usar. (Heredado de UrlEditor) |
Métodos
| Nombre | Description |
|---|---|
| EditValue(IServiceProvider, Object) |
Edita el valor del objeto especificado utilizando el estilo del editor indicado por el GetEditStyle() método . (Heredado de UITypeEditor) |
| EditValue(ITypeDescriptorContext, IServiceProvider, Object) |
Edita el valor del objeto especificado mediante el estilo del editor proporcionado por el GetEditStyle(ITypeDescriptorContext) método . (Heredado de UrlEditor) |
| Equals(Object) |
Determina si el objeto especificado es igual al objeto actual. (Heredado de Object) |
| GetEditStyle() |
Obtiene el estilo del editor utilizado por el EditValue(IServiceProvider, Object) método . (Heredado de UITypeEditor) |
| GetEditStyle(ITypeDescriptorContext) |
Obtiene el estilo de edición del EditValue(ITypeDescriptorContext, IServiceProvider, Object) método . (Heredado de UrlEditor) |
| GetHashCode() |
Actúa como función hash predeterminada. (Heredado de Object) |
| GetPaintValueSupported() |
Indica si este editor admite pintar una representación del valor de un objeto. (Heredado de UITypeEditor) |
| GetPaintValueSupported(ITypeDescriptorContext) |
Indica si el contexto especificado admite pintar una representación del valor de un objeto dentro del contexto especificado. (Heredado de UITypeEditor) |
| GetType() |
Obtiene el Type de la instancia actual. (Heredado de Object) |
| MemberwiseClone() |
Crea una copia superficial del Objectactual. (Heredado de Object) |
| PaintValue(Object, Graphics, Rectangle) |
Pinta una representación del valor del objeto especificado en el lienzo especificado. (Heredado de UITypeEditor) |
| PaintValue(PaintValueEventArgs) |
Pinta una representación del valor de un objeto utilizando el especificado PaintValueEventArgs. (Heredado de UITypeEditor) |
| ToString() |
Devuelve una cadena que representa el objeto actual. (Heredado de Object) |