MdbDataFileEditor Kelas
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menyediakan antarmuka pengguna waktu desain untuk memilih file database 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
- Warisan
Contoh
Contoh kode berikut menunjukkan cara mengaitkan instans MdbDataFileEditor kelas dengan properti yang terkandung dalam kontrol kustom. Saat Anda mengedit properti kontrol pada permukaan desain, MdbDataFileEditor kelas menyediakan antarmuka pengguna untuk memilih dan mengedit nama file database Access untuk nilai properti.
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
Keterangan
Objek MdbDataFileEditor digunakan pada waktu desain untuk memilih dan mengedit URL untuk file database Microsoft Access (.mdb), lalu menetapkan URL ke properti kontrol. Misalnya, AccessDataSource kontrol menggunakan kelas pada MdbDataFileEditor waktu desain untuk mengatur nilai DataFile properti.
EditorAttribute Gunakan atribut untuk mengaitkan MdbDataFileEditor dengan properti. Ketika properti terkait diedit pada permukaan desain, host perancang memanggil EditValue metode . Metode ini EditValue menggunakan metode , yang pada gilirannya BuildUrl menampilkan antarmuka pengguna untuk memilih URL, lalu mengembalikan URL yang dipilih oleh pengguna. Metode menunjukkan GetEditStyle gaya tampilan antarmuka pengguna.
Mendapatkan kelas dari MdbDataFileEditor untuk menentukan editor kustom untuk properti URL database Access. Misalnya, kelas turunan dapat mengambil alih EditValue metode , lalu memanggil BuildUrl metode dengan kustom Filter atau Caption nilai.
Konstruktor
| Nama | Deskripsi |
|---|---|
| MdbDataFileEditor() |
Menginisialisasi instans baru dari kelas MdbDataFileEditor. |
Properti
| Nama | Deskripsi |
|---|---|
| Caption |
Mendapatkan keterangan untuk ditampilkan pada kotak dialog pilihan. |
| Filter |
Mendapatkan opsi filter URL untuk editor, yang digunakan untuk memfilter item yang muncul dalam kotak dialog pemilihan URL. |
| IsDropDownResizable |
Mendapatkan nilai yang menunjukkan apakah editor drop-down harus dapat diubah bentuknya oleh pengguna. (Diperoleh dari UITypeEditor) |
| Options |
Mendapatkan opsi untuk digunakan penyusun URL. (Diperoleh dari UrlEditor) |
Metode
| Nama | Deskripsi |
|---|---|
| EditValue(IServiceProvider, Object) |
Mengedit nilai objek yang ditentukan menggunakan gaya editor yang ditunjukkan GetEditStyle() oleh metode . (Diperoleh dari UITypeEditor) |
| EditValue(ITypeDescriptorContext, IServiceProvider, Object) |
Mengedit nilai objek yang ditentukan menggunakan gaya editor yang disediakan oleh GetEditStyle(ITypeDescriptorContext) metode . (Diperoleh dari UrlEditor) |
| Equals(Object) |
Menentukan apakah objek yang ditentukan sama dengan objek saat ini. (Diperoleh dari Object) |
| GetEditStyle() |
Mendapatkan gaya editor yang digunakan oleh EditValue(IServiceProvider, Object) metode . (Diperoleh dari UITypeEditor) |
| GetEditStyle(ITypeDescriptorContext) |
Mendapatkan gaya EditValue(ITypeDescriptorContext, IServiceProvider, Object) pengeditan metode . (Diperoleh dari UrlEditor) |
| GetHashCode() |
Berfungsi sebagai fungsi hash default. (Diperoleh dari Object) |
| GetPaintValueSupported() |
Menunjukkan apakah editor ini mendukung pengecatan representasi nilai objek. (Diperoleh dari UITypeEditor) |
| GetPaintValueSupported(ITypeDescriptorContext) |
Menunjukkan apakah konteks yang ditentukan mendukung pengecatan representasi nilai objek dalam konteks yang ditentukan. (Diperoleh dari UITypeEditor) |
| GetType() |
Mendapatkan Type instans saat ini. (Diperoleh dari Object) |
| MemberwiseClone() |
Membuat salinan dangkal dari Objectsaat ini. (Diperoleh dari Object) |
| PaintValue(Object, Graphics, Rectangle) |
Melukis representasi nilai objek yang ditentukan ke kanvas yang ditentukan. (Diperoleh dari UITypeEditor) |
| PaintValue(PaintValueEventArgs) |
Melukis representasi nilai objek menggunakan yang ditentukan PaintValueEventArgs. (Diperoleh dari UITypeEditor) |
| ToString() |
Mengembalikan string yang mewakili objek saat ini. (Diperoleh dari Object) |