XsdSchemaFileEditor 类

定义

提供用于选择 XML 架构定义文件的设计时用户界面。

public ref class XsdSchemaFileEditor : System::Web::UI::Design::UrlEditor
public class XsdSchemaFileEditor : System.Web.UI.Design.UrlEditor
type XsdSchemaFileEditor = class
    inherit UrlEditor
Public Class XsdSchemaFileEditor
Inherits UrlEditor
继承
XsdSchemaFileEditor

示例

下面的代码示例演示如何将 类的 XsdSchemaFileEditor 实例与自定义控件中包含的属性相关联。 在设计图面上编辑控件属性时, XsdSchemaFileEditor 类提供用户界面来选择和编辑属性值的 XML 架构定义文件名。

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 XML schema file property.  Indicate that the
        // property can be edited at design-time with the XsdSchemaFileEditor class.
        [EditorAttribute(typeof(System.Web.UI.Design.XsdSchemaFileEditor), 
                         typeof(System.Drawing.Design.UITypeEditor))]
        public string SchemaFileName
        {
            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 XSD schema file name property.  Indicate that the
        ' property can be edited at design-time with the XsdSchemaFileEditor class.
        <EditorAttribute(GetType(System.Web.UI.Design.XsdSchemaFileEditor), _
                         GetType(System.Drawing.Design.UITypeEditor))> _
        Public Property SchemaFileName() 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

注解

XsdSchemaFileEditor对象在设计时用于选择和编辑 XML 架构定义文件 (.xsd) 的 URL,并将 URL 分配给控件属性。

EditorAttribute使用 特性将 与 属性相关联XsdSchemaFileEditor。 在设计图面上编辑关联的属性时,设计器宿主将调用 EditValue 方法。 方法 EditValue 使用 BuildUrl 方法,该方法反过来显示用于选择 URL 的用户界面,然后返回用户选择的 URL。 方法 GetEditStyle 指示用户界面的显示样式。

XsdSchemaFileEditor 派生类,以定义 XML 架构 URL 属性的自定义编辑器。 例如,派生类可以重写 EditValue 方法,然后使用自定义 FilterCaption 值调用 BuildUrl 方法。

构造函数

XsdSchemaFileEditor()

初始化 XsdSchemaFileEditor 类的新实例。

属性

Caption

获取要在选择对话框中显示的标题。

Filter

获取编辑器的 URL 筛选选项,用于对 URL 选择对话框中出现的项进行筛选。

IsDropDownResizable

获取一个值,该值指示是否应由用户调整下拉编辑器的大小。

(继承自 UITypeEditor)
Options

获取 URL 生成器要使用的选项。

(继承自 UrlEditor)

方法

EditValue(IServiceProvider, Object)

使用 GetEditStyle() 方法所指示的编辑器样式编辑指定对象的值。

(继承自 UITypeEditor)
EditValue(ITypeDescriptorContext, IServiceProvider, Object)

使用 GetEditStyle(ITypeDescriptorContext) 方法所提供的编辑器样式编辑指定对象的值。

(继承自 UrlEditor)
Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetEditStyle()

获取由 EditValue(IServiceProvider, Object) 方法使用的编辑器样式。

(继承自 UITypeEditor)
GetEditStyle(ITypeDescriptorContext)

获取 EditValue(ITypeDescriptorContext, IServiceProvider, Object) 方法的编辑样式。

(继承自 UrlEditor)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetPaintValueSupported()

指示该编辑器是否支持绘制对象值的表示形式。

(继承自 UITypeEditor)
GetPaintValueSupported(ITypeDescriptorContext)

指示指定的上下文是否支持在指定的上下文内绘制对象值的表示形式。

(继承自 UITypeEditor)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
PaintValue(Object, Graphics, Rectangle)

将指定对象值表示形式绘制到指定的画布上。

(继承自 UITypeEditor)
PaintValue(PaintValueEventArgs)

使用指定的 PaintValueEventArgs 绘制某个对象的值的表示形式。

(继承自 UITypeEditor)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅