MdbDataFileEditor 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
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
- 상속
예제
다음 코드 예제에서는 사용자 지정 컨트롤 내에 포함 된 속성과 클래스의 MdbDataFileEditor 인스턴스를 연결 하는 방법을 보여 줍니다. 디자인 화면에서 MdbDataFileEditor 컨트롤 속성을 편집할 때 클래스는 속성 값에 대한 Access 데이터베이스 파일 이름을 선택하고 편집하는 사용자 인터페이스를 제공합니다.
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
설명
MdbDataFileEditor 디자인 타임에 개체를 사용하여 Microsoft Access 데이터베이스 파일(.mdb)의 URL을 선택하고 편집한 다음, 컨트롤 속성에 URL을 할당합니다. 예를 들어 컨트롤은 AccessDataSource 디자인 타임에 MdbDataFileEditor 클래스를 사용하여 속성 값을 DataFile 설정합니다.
EditorAttribute 특성을 사용하여 속성과 연결 MdbDataFileEditor 합니다. 디자인 화면에서 연결된 속성을 편집하면 디자이너 호스트가 메서드를 호출합니다 EditValue . 이 메서드는 EditValue 메서드를 BuildUrl 사용하여 URL을 선택하기 위한 사용자 인터페이스를 표시한 다음 사용자가 선택한 URL을 반환합니다. 이 메서드는 GetEditStyle 사용자 인터페이스의 표시 스타일을 나타냅니다.
Access 데이터베이스 URL 속성에 MdbDataFileEditor 대한 사용자 지정 편집기를 정의하기 위해 클래스를 파생합니다. 예를 들어 파생 클래스는 메서드를 재정의 EditValue 한 다음 사용자 지정 Filter 또는 Caption 값으로 메서드를 호출할 BuildUrl 수 있습니다.
생성자
| Name | Description |
|---|---|
| MdbDataFileEditor() |
MdbDataFileEditor 클래스의 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| Caption |
선택 대화 상자에 표시할 캡션을 가져옵니다. |
| Filter |
URL 선택 대화 상자에 나타나는 항목을 필터링하는 데 사용되는 편집기 URL 필터 옵션을 가져옵니다. |
| IsDropDownResizable |
사용자가 드롭다운 편집기를 조정할 수 있는지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 UITypeEditor) |
| Options |
URL 작성기에서 사용할 옵션을 가져옵니다. (다음에서 상속됨 UrlEditor) |