MColorBox
Home
Components
MColorBox
About component
MColorBox serves as a simple System.Drawing.Color holder.
How to use it?
Like other controls, MColorBox can be simply droped from toolbox on the form. If you are not using IDE with integrated form designer (like Visual Studio), you can always create color-box programmatically:
// Initialize color-box first
MColorBox box = new MColorBox();
// Set location
box.Location = new Point(50, 50);
// Set color
box.Color = Color.Blue;
// Don't forget to add our newly created
// color-box to form's control collection.
targetForm.Controls.Add(box);
using System;
using System.Windows.Forms;
using Minimal.Components;
namespace Demo
{
public partial class MyForm : Form
{
// Initialize color-box first
MColorBox box = new MColorBox();
// Form constructor
public MyForm()
{
InitializeComponent();
// Set size and location
box.Location = new Point(50, 50);
// Set color
box.Color = Color.Red;
// Don't forget to add our newly created
// color-box to form's control collection.
Controls.Add(box);
}
}
}
Code example asumes, that targetForm variable is form where you want to have your color-box placed. If you are working inside a class derived from System.Windows.Forms.Form, you can of course replace targetForm variable with this keyword or in latest version of C# omit form reference completely. See second example above. Color of the color-box can be set using the Color property. By default, multiple color-boxes can be ticked at once. By changing MultipleTicks property to false you can force check-box like behaviour. This will ensure that only one color-box per parent control is allowed to be ticked.
Theming
Border line and inner check-mark of the MColorBox automatically fades to match currently set theme and color, which is set on color-box.
ColorBox types
There are two basic types of color-box. Circular and rectangular. They can be set by using Type property and ColorBoxType enum.
Class content
| Assembly |
Minimal.dll |
| Namespace |
Minimal.Components |
| Inheritance |
MBufferedPanel |
| Attributes |
Minimal.Components.Design.ColorBoxDesigner |
| Implements |
IMComponent |
This list doesn’t include content derived from the parent class. See MBufferedPanel documentation for a complete list of items.
Constructors
| Name |
Description |
|
| MColorBox() |
Initializes a new instance of the MColorBox class. |
|
Properties
| Name |
Description |
Type |
| Component |
Handles life-cycle of the M-Component. |
MComponent |
| Color |
Color which is color-box currently holding. |
Color |
| Selected |
True if color-box is selected. |
bool |
| CustomTheme |
Component's custom theme. Will override default parent M-form or application-wide theme. |
Theme |
| MultipleTicks |
True, if there can be multiple color-boxes checked at the same time on the same parent control. |
bool |
| Type |
Type of the color-box. |
ColorBoxType |
Fields
| Name |
Description |
Type |
| - |
- |
- |
Events
| Name |
Description |
Type |
| SelectedChanged |
Fires when the Selected property is changed. |
PropertyChangedEventHandler |
| CustomThemeChanged |
Fires when the CustomTheme property is changed. |
PropertyChangedEventHandler |
Methods
| Name |
Description |
Returns |
| - |
- |
- |