MdbDataFileEditor Klasa
Definicja
Ważny
Niektóre informacje dotyczą produktów przedpremierowych, które mogą zostać znacznie zmodyfikowane przed premierą. Microsoft nie udziela żadnych gwarancji, ani wyraźnych, ani domniemanych, dotyczących informacji podanych tutaj.
Udostępnia interfejs użytkownika czasu projektowania do wybierania pliku bazy danych 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
- Dziedziczenie
Przykłady
W poniższym przykładzie kodu pokazano, jak skojarzyć wystąpienie MdbDataFileEditor klasy z właściwością zawartą w kontrolce niestandardowej. Podczas edytowania właściwości kontrolki na powierzchni projektowej MdbDataFileEditor klasa udostępnia interfejs użytkownika, aby wybrać i edytować nazwę pliku bazy danych programu Access dla wartości właściwości.
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
Uwagi
Obiekt MdbDataFileEditor jest używany w czasie projektowania do wybierania i edytowania adresu URL pliku bazy danych programu Microsoft Access (mdb), a następnie przypisania adresu URL do właściwości kontrolki. Na przykład kontrolka AccessDataSource używa MdbDataFileEditor klasy w czasie projektowania, aby ustawić wartość DataFile właściwości.
Użyj atrybutu EditorAttribute , aby skojarzyć MdbDataFileEditor właściwość z właściwością. Gdy skojarzona właściwość jest edytowana na powierzchni projektowej, host projektanta wywołuje metodę EditValue . Metoda EditValue używa BuildUrl metody , która z kolei wyświetla interfejs użytkownika do wybierania adresu URL, a następnie zwraca adres URL wybrany przez użytkownika. Metoda GetEditStyle wskazuje styl wyświetlania interfejsu użytkownika.
Utwórz klasę z MdbDataFileEditor klasy , aby zdefiniować edytor niestandardowy dla właściwości adresu URL bazy danych programu Access. Na przykład klasa pochodna może zastąpić EditValue metodę, a następnie wywołać BuildUrl metodę za pomocą niestandardowej Filter lub Caption wartości.
Konstruktorów
| Nazwa | Opis |
|---|---|
| MdbDataFileEditor() |
Inicjuje nowe wystąpienie klasy MdbDataFileEditor. |
Właściwości
| Nazwa | Opis |
|---|---|
| Caption |
Pobiera podpis do wyświetlenia w oknie dialogowym wyboru. |
| Filter |
Pobiera opcje filtru adresu URL edytora, które służą do filtrowania elementów wyświetlanych w oknie dialogowym wyboru adresu URL. |
| IsDropDownResizable |
Pobiera wartość wskazującą, czy edytory listy rozwijanej powinny być zmienialne przez użytkownika. (Dziedziczone od UITypeEditor) |
| Options |
Pobiera opcje konstruktora adresów URL do użycia. (Dziedziczone od UrlEditor) |
Metody
| Nazwa | Opis |
|---|---|
| EditValue(IServiceProvider, Object) |
Edytuje wartość określonego obiektu przy użyciu stylu edytora wskazanego przez metodę GetEditStyle() . (Dziedziczone od UITypeEditor) |
| EditValue(ITypeDescriptorContext, IServiceProvider, Object) |
Edytuje wartość określonego obiektu przy użyciu stylu edytora dostarczonego przez metodę GetEditStyle(ITypeDescriptorContext) . (Dziedziczone od UrlEditor) |
| Equals(Object) |
Określa, czy dany obiekt jest taki sam, jak bieżący obiekt. (Dziedziczone od Object) |
| GetEditStyle() |
Pobiera styl edytora używany przez metodę EditValue(IServiceProvider, Object) . (Dziedziczone od UITypeEditor) |
| GetEditStyle(ITypeDescriptorContext) |
Pobiera styl edycji EditValue(ITypeDescriptorContext, IServiceProvider, Object) metody. (Dziedziczone od UrlEditor) |
| GetHashCode() |
Służy jako domyślna funkcja skrótu. (Dziedziczone od Object) |
| GetPaintValueSupported() |
Wskazuje, czy ten edytor obsługuje malowanie reprezentacji wartości obiektu. (Dziedziczone od UITypeEditor) |
| GetPaintValueSupported(ITypeDescriptorContext) |
Wskazuje, czy określony kontekst obsługuje malowanie reprezentacji wartości obiektu w określonym kontekście. (Dziedziczone od UITypeEditor) |
| GetType() |
Type Pobiera bieżące wystąpienie. (Dziedziczone od Object) |
| MemberwiseClone() |
Tworzy płytkią kopię bieżącego Objectelementu . (Dziedziczone od Object) |
| PaintValue(Object, Graphics, Rectangle) |
Maluje reprezentację wartości określonego obiektu na określoną kanwę. (Dziedziczone od UITypeEditor) |
| PaintValue(PaintValueEventArgs) |
Maluje reprezentację wartości obiektu przy użyciu określonego PaintValueEventArgsobiektu . (Dziedziczone od UITypeEditor) |
| ToString() |
Zwraca ciąg reprezentujący bieżący obiekt. (Dziedziczone od Object) |