ControlDesigner.ViewControl プロパティ
アセンブリ: System.Design (system.design.dll 内)

Dim instance As ControlDesigner Dim value As Control value = instance.ViewControl instance.ViewControl = value
/** @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. } }


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からControlDesigner.ViewControl プロパティを検索する場合は、下記のリンクをクリックしてください。

- ControlDesigner.ViewControl プロパティのページへのリンク