ControlDesigner.ViewControl プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ControlDesigner.ViewControl プロパティの意味・解説 

ControlDesigner.ViewControl プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

デザインHTML マークアッププレビュー用に使用できる Web サーバー コントロール取得または設定します

名前空間: System.Web.UI.Design
アセンブリ: System.Design (system.design.dll 内)
構文構文

Dim instance As ControlDesigner
Dim value As Control

value = instance.ViewControl

instance.ViewControl = value
public Control ViewControl { get; set;
 }
/** @property */
public Control get_ViewControl ()

/** @property */
public void set_ViewControl (Control value)

プロパティ
デザインHTML マークアップ生成するために基本クラス使用する Control

解説解説

ViewControl プロパティは、UsePreviewControl プロパティ使用して戻り値決定します

UsePreviewControl プロパティtrue場合ViewControl プロパティコントロール一時コピー返します一時コントロール加えられ変更永続化されません。

UsePreviewControl プロパティfalse場合ViewControl プロパティコントロールComponent プロパティインスタンス返しますコントロールインスタンス加えられ変更永続化されます

SupportsPreviewControlAttribute オブジェクト内の SupportsPreviewControl 設定は、UsePreviewControl プロパティの値を設定するために使用します。したがってSupportsPreviewControl設定により、基本 ControlDesigner クラスViewControl プロパティによって返されるコントロール種類決定されます。SupportsPreviewControlAttributeコントロール デザイナ宣言内で指定されていない場合ControlDesigner動作SupportsPreviewControl プロパティfalse設定した場合同じになります

使用例使用例

SupportsPreviewControlAttribute 属性使用してコントロール デザイナマークする方法次のコード例示します。このコード例は、Label クラスから Web サーバー コントロール派生し、そのコントロールカスタム コントロール デザイナ実装関連付けます。コントロール デザイナ クラス宣言は、true設定されSupportsPreviewControl 属性マークされます。コントロール デザイナは、GetDesignTimeHtml メソッドオーバーライドし、デザイン時にコントロールText プロパティ斜体表示します

Imports Microsoft.VisualBasic
Imports System
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.Reflection

Namespace ControlDesignerSamples.VB

    ' Derive a simple Web control from Label to render a text string.
    ' Associate this control with the SimpleTextControlDesigner.
    <DesignerAttribute("ControlDesignerSamples.CS.SimpleTextControlDesigner"),
 _
    ToolboxData("<{0}:MyLabelControl Runat=""Server""><{0}:MyLabelControl>")>
 _
    Public Class MyLabelControl
        Inherits Label

        ' Use the Label control implementation, but associate
        ' the derived class with the custom control designer.
    End Class


    ' Mark the designer with the SupportsPreviewControlAttribute set
    ' to true.  This means the base.UsePreviewControl returns true,
    ' and base.ViewControl returns a temporary preview copy of the control.
    <SupportsPreviewControl(True)> _
    Public Class SimpleTextControlDesigner
        Inherits TextControlDesigner

        ' Override the base GetDesignTimeHtml method to display 
        ' the design time text in italics.
        Public Overrides Function
 GetDesignTimeHtml() As String
            Dim html As String
 = String.Empty

            Try
                ' Get the ViewControl for the associated control.
                Dim ctrl As Label = CType(ViewControl,
 Label)

                ' Set the default text, if necessary
                If ctrl.Text.Length = 0 Then
                    ctrl.Text = "Sample Text"
                End If

                ' Set the style to italic
                ctrl.Style.Add(HtmlTextWriterStyle.FontStyle, "italic")

                ' Let the base class create the HTML markup
                html = MyBase.GetDesignTimeHtml()
            Catch ex As Exception
                If String.IsNullOrEmpty(html)
 Then
                    ' Display the exception message
                    html = GetErrorDesignTimeHtml(ex)
                End If
            End Try

            Return html
        End Function

    End Class
End Namespace
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.Reflection;

namespace ControlDesignerSamples.CS
{
    // Define a simple designer associated with a 
    // simple text web control.
    
    // Mark the designer with the SupportsPreviewControlAttribute set
    // to true.  This means the base.UsePreviewControl returns true
,
    // and base.ViewControl returns a temporary preview copy of the
 control.
    [SupportsPreviewControl(true)]
    public class SimpleTextControlDesigner
 : TextControlDesigner
    {        
        // Override the base GetDesignTimeHtml method to display 
        // the design time text in italics.
        public override string GetDesignTimeHtml()
        {
            string html = String.Empty;
 
            try
            {
                // Initialize the return string to the default
                // design time html of the base TextControlDesigner.
                html = base.GetDesignTimeHtml();

                // Get the ViewControl for the associated control.
                Label ctrl = (Label)ViewControl;

                ctrl.Style.Add(HtmlTextWriterStyle.FontStyle, "Italic");
                html = base.GetDesignTimeHtml();

            }
            catch (System.Exception e)
            {
               if (String.IsNullOrEmpty(html))
               {
                   html = GetErrorDesignTimeHtml(e);
               }
            }
            
            return html;
        }

    }

    // Derive a simple Web control from Label to render a text string.
    // Associate this control with the SimpleTextControlDesigner.
    [DesignerAttribute("ControlDesignerSamples.CS.SimpleTextControlDesigner")
,
    ToolboxData("<{0}:MyLabelControl Runat=\"Server\"><{0}:MyLabelControl>")]
    public class MyLabelControl : Label
    {
        // Use the Label control implementation, but associate
        // the derived class with the custom control designer.
    }
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ControlDesigner クラス
ControlDesigner メンバ
System.Web.UI.Design 名前空間
SupportsPreviewControlAttribute
ControlDesigner.UsePreviewControl プロパティ
GetViewRendering
SupportsPreviewControlAttribute
PreviewControlDesigner
その他の技術情報
ASP.NET コントロール デザイナ概要
Web フォームデザインサポート


このページでは「.NET Framework クラス ライブラリ リファレンス」からControlDesigner.ViewControl プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からControlDesigner.ViewControl プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からControlDesigner.ViewControl プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ControlDesigner.ViewControl プロパティ」の関連用語

ControlDesigner.ViewControl プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ControlDesigner.ViewControl プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS