ColorBuilder Class
Provides an HTML color string builder at design time that allows a user to select a color.
Assembly: System.Design (in System.Design.dll)
| Name | Description | |
|---|---|---|
![]() ![]() | BuildColor(IComponent, Control, String) | Starts a color editor to build an HTML color property value. |
![]() | Equals(Object) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
The BuildColor method starts a user interface for selecting a color value.
The ColorBuilder class is 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.
// 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 designer provides a designer verb menu command to launch the // BuildColor method of the ColorBuilder. [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")] [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] 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); } }
Available since 1.1
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
.jpeg?cs-save-lang=1&cs-lang=csharp)
.jpeg?cs-save-lang=1&cs-lang=csharp)