MailFileEditor 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
디자인 타임에 속성의 메일 파일 이름을 선택하고 편집하기 위한 사용자 인터페이스를 제공합니다.
public ref class MailFileEditor : System::Web::UI::Design::UrlEditor
public class MailFileEditor : System.Web.UI.Design.UrlEditor
type MailFileEditor = class
inherit UrlEditor
Public Class MailFileEditor
Inherits UrlEditor
- 상속
예제
다음 코드 예제에서는 사용자 지정 컨트롤 내에 포함 된 속성과 클래스의 MailFileEditor 인스턴스를 연결 하는 방법을 보여 줍니다. 디자인 화면에서 MailFileEditor 컨트롤 속성을 편집할 때 클래스는 속성 값에 대한 메일 파일 이름을 선택하고 편집하는 사용자 인터페이스를 제공합니다.
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;
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 file name property. Indicate that the
// property can be edited at design-time with the MailFileEditor class.
[EditorAttribute(typeof(System.Web.UI.Design.MailFileEditor),
typeof(System.Drawing.Design.UITypeEditor))]
public string MailFileName
{
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 (System.IO.File.Exists(_filename))
{
DateTime lastChangedStamp = System.IO.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
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 mail file name property. Indicate that the
' property can be edited at design-time with the MailFileEditor class.
<EditorAttribute(GetType(System.Web.UI.Design.MailFileEditor), _
GetType(System.Drawing.Design.UITypeEditor))> _
Public Property MailFileName() 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 System.IO.File.Exists(_filename) Then
Dim lastChangedStamp As DateTime
lastChangedStamp = System.IO.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
설명
클래스 MailFileEditor 는 UITypeEditor 디자인 타임에 메일 파일 이름을 문자열로 선택 및 편집하고 컨트롤 속성에 문자열을 할당하는 데 사용할 수 있는 개체입니다. 예를 들어 컨트롤은 EmbeddedMailObject 디자인 타임에 MailFileEditor 클래스를 사용하여 속성 값을 Path 설정합니다.
EditorAttribute 특성을 사용하여 속성과 연결 MailFileEditor 합니다. 디자인 화면에서 연결된 속성을 편집하면 디자이너 호스트가 메서드를 호출합니다 EditValue . 이 메서드는 EditValue 필터링된 파일 목록에서 메일 파일 이름을 선택하는 대화 상자를 표시하고 사용자가 선택한 파일 이름을 반환합니다. 이 메서드는 GetEditStyle 사용자 인터페이스의 표시 스타일을 나타냅니다.
메일 파일 이름 속성에 MailFileEditor 대한 사용자 지정 편집기를 정의하려면 클래스를 파생합니다. 예를 들어 파생 클래스는 메서드를 재정의 EditValue 하고 사용자 지정 메일 파일 필터 또는 제목이 있는 OpenFileDialog 인스턴스를 표시할 수 있습니다.
생성자
| Name | Description |
|---|---|
| MailFileEditor() |
MailFileEditor 클래스의 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| Caption |
편집기 대화 상자의 캡션을 가져옵니다. |
| Filter |
대화 상자의 파일 필터 문자열(예: "*.txt")을 가져옵니다. |
| IsDropDownResizable |
사용자가 드롭다운 편집기를 조정할 수 있는지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 UITypeEditor) |
| Options |
URL 작성기에서 사용할 옵션을 가져옵니다. (다음에서 상속됨 UrlEditor) |