ColorBuilder Class
Provides an HTML color string builder at design time that allows a user to select a color.
For a list of all members of this type, see ColorBuilder Members.
System.Object
System.Web.UI.Design.ColorBuilder
[Visual Basic] NotInheritable Public Class ColorBuilder [C#] public sealed class ColorBuilder [C++] public __gc __sealed class ColorBuilder [JScript] public class ColorBuilder
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
The BuildColor method starts a user interface for selecting a color value.The ColorBuilder class was not intended for use outside of the design time environment. ColorBuilder requires the IWebFormsBuilderUIService, which is typically available within a Web Forms project at design time. If you want to build HTML color strings, you may want to implement a method that converts the RGB values of a Color object to an HTML-compatible RRGGBB format string. If you intend to use a control to select a color or configure a color, you can build a user interface for this, or you may want to use a PropertyGrid control which allows you to edit Color properties with the default ColorEditor providing a color selection interface.
Example
[Visual Basic] ' 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] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Web.UI.Design
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
Assembly: System.Design (in System.Design.dll)