MdbDataFileEditor クラス

定義

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 含まれるプロパティに関連付ける方法を示します。 デザインサーフェイスでコントロール プロパティを編集すると、 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 、ユーザー インターフェイスの表示スタイルを示します。

からクラス MdbDataFileEditor を派生して、Access データベース URL プロパティのカスタム エディターを定義します。 たとえば、派生クラスは メソッドをEditValueオーバーライドし、カスタムFilterまたはCaption値を使用して BuildUrl メソッドを呼び出すことができます。

コンストラクター

MdbDataFileEditor()

MdbDataFileEditor クラスの新しいインスタンスを初期化します。

プロパティ

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)

適用対象

こちらもご覧ください