デザイン時にユーザーが色を選択できるようにする HTML カラー文字列ビルダを提供します。
この型のすべてのメンバの一覧については、ColorBuilder メンバ を参照してください。
System.Object
System.Web.UI.Design.ColorBuilder
NotInheritable Public Class ColorBuilder
[C#]
public sealed class ColorBuilder
[C++]
public __gc __sealed class ColorBuilder
[JScript]
public class ColorBuilder
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
BuildColor メソッドは、カラー値を選択するためのユーザー インターフェイスを起動します。 ColorBuilder クラスは、デザイン時環境以外での使用を想定したものではありません。 ColorBuilder は IWebFormsBuilderUIService を必要とします。これは通常、デザイン時に Web フォーム プロジェクトで使用できます。HTML カラー文字列をビルドする場合は、 Color オブジェクトの RGB 値を HTML 互換の RRGGBB 形式の文字列に変換するメソッドを実装します。色の選択または設定にコントロールを使用する場合は、このためのユーザー インターフェイスを作成することもできますし、色選択のインターフェイスを提供する既定の ColorEditor で Color のプロパティの編集機能を提供する PropertyGrid コントロールを使用することもできます。
使用例
' Create a parent control.
Dim c As New System.Windows.Forms.Control()
c.CreateControl()
' Launch the Color Builder using the specified control
' parent and an initial HTML format ("RRGGBB") color string.
System.Web.UI.Design.ColorBuilder.BuildColor(Me.Component, c, "405599")
[C#]
// Create a parent control.
System.Windows.Forms.Control c = new System.Windows.Forms.Control();
c.CreateControl();
// Launch the Color Builder using the specified control
// parent and an initial HTML format ("RRGGBB") color string.
System.Web.UI.Design.ColorBuilder.BuildColor(this.Component, c, "405599");
[C++]
// Create a parent control.
System::Windows::Forms::Control* c = new System::Windows::Forms::Control();
c->CreateControl();
// Launch the Color Builder using the specified control
// parent and an initial HTML format (S"RRGGBB") color String*.
System::Web::UI::Design::ColorBuilder::BuildColor(this->Component, c, S"405599");
[Visual Basic]
' Example designer provides a designer verb menu command to launch the
' BuildColor method of the ColorBuilder.
Public Class ColorBuilderDesigner
Inherits System.Web.UI.Design.UserControlDesigner
Public Sub New()
End Sub
' Provides a designer verb menu command for invoking the BuildColor
' method of the ColorBuilder.
Public Overrides ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection
Get
Dim dvc As New DesignerVerbCollection()
dvc.Add(New DesignerVerb("Launch Color Builder UI", New EventHandler(AddressOf Me.launchColorBuilder)))
Return dvc
End Get
End Property
' This method handles the "Launch Color Builder UI" menu command.
' Invokes the BuildColor method of the System.Web.UI.Design.ColorBuilder.
Private Sub launchColorBuilder(ByVal sender As Object, ByVal e As EventArgs)
' Create a parent control.
Dim c As New System.Windows.Forms.Control()
c.CreateControl()
' Launch the Color Builder using the specified control
' parent and an initial HTML format ("RRGGBB") color string.
System.Web.UI.Design.ColorBuilder.BuildColor(Me.Component, c, "405599")
End Sub
End Class
' Example Web control displays the value of its text property.
' This control is associated with the ColorBuilderDesigner.
<DesignerAttribute(GetType(ColorBuilderDesigner), GetType(IDesigner))> _
Public Class ColorBuilderControl
Inherits System.Web.UI.WebControls.WebControl
Private [text_] As String
<Bindable(True), Category("Appearance"), DefaultValue("")> _
Public Property [Text]() As String
Get
Return [text_]
End Get
Set(ByVal Value As String)
[text_] = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As HtmlTextWriter)
output.Write([Text])
End Sub
End Class
[C#]
// Example designer provides a designer verb menu command to launch the
// BuildColor method of the ColorBuilder.
public class ColorBuilderDesigner : System.Web.UI.Design.UserControlDesigner
{
public ColorBuilderDesigner()
{
}
// Provides a designer verb menu command for invoking the BuildColor
// method of the ColorBuilder.
public override System.ComponentModel.Design.DesignerVerbCollection Verbs
{
get
{
DesignerVerbCollection dvc = new DesignerVerbCollection();
dvc.Add( new DesignerVerb("Launch Color Builder UI", new EventHandler(this.launchColorBuilder)) );
return dvc;
}
}
// This method handles the "Launch Color Builder UI" menu command.
// Invokes the BuildColor method of the System.Web.UI.Design.ColorBuilder.
private void launchColorBuilder(object sender, EventArgs e)
{
// Create a parent control.
System.Windows.Forms.Control c = new System.Windows.Forms.Control();
c.CreateControl();
// Launch the Color Builder using the specified control
// parent and an initial HTML format ("RRGGBB") color string.
System.Web.UI.Design.ColorBuilder.BuildColor(this.Component, c, "405599");
}
}
// Example Web control displays the value of its text property.
// This control is associated with the ColorBuilderDesigner.
[DesignerAttribute(typeof(ColorBuilderDesigner), typeof(IDesigner))]
public class ColorBuilderControl : System.Web.UI.WebControls.WebControl
{
private string text;
[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
protected override void Render(HtmlTextWriter output)
{
output.Write(Text);
}
}
[C++]
// Example designer provides a designer verb menu command to launch the
// BuildColor method of the ColorBuilder.
public __gc class ColorBuilderDesigner :
public System::Web::UI::Design::UserControlDesigner {
public:
ColorBuilderDesigner() {
}
// Provides a designer verb menu command for invoking the BuildColor
// method of the ColorBuilder.
public:
__property System::ComponentModel::Design::DesignerVerbCollection* get_Verbs() {
DesignerVerbCollection* dvc = new DesignerVerbCollection();
dvc->Add(new DesignerVerb(S"Launch Color Builder UI",
new EventHandler(this,&ColorBuilderDesigner::launchColorBuilder)));
return dvc;
}
// This method handles the S"Launch Color Builder UI" menu command.
// Invokes the BuildColor method of the System::Web::UI::Design.ColorBuilder.
private:
void launchColorBuilder(Object* /*sender*/, EventArgs* /*e*/) {
// Create a parent control.
System::Windows::Forms::Control* c = new System::Windows::Forms::Control();
c->CreateControl();
// Launch the Color Builder using the specified control
// parent and an initial HTML format (S"RRGGBB") color String*.
System::Web::UI::Design::ColorBuilder::BuildColor(this->Component, c, S"405599");
}
};
// Example Web control displays the value of its text property.
// This control is associated with the ColorBuilderDesigner.
[DesignerAttribute(__typeof(ColorBuilderDesigner), __typeof(IDesigner))]
public __gc class ColorBuilderControl : public System::Web::UI::WebControls::WebControl {
private:
String* text;
public:
[Bindable(true),
Category(S"Appearance"),
DefaultValue(S"")]
__property String* get_Text() {
return text;
}
__property void set_Text(String* value) {
text = value;
}
protected:
void Render(HtmlTextWriter* output) {
output->Write(Text);
}
};
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Web.UI.Design
プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System.Design (System.Design.dll 内)