Overview

BeepControlWidget is a paint-based WinForms widget that inherits from BaseControl. It uses an IWidgetPainter pipeline to render rich visuals without child controls. The Style property selects one of 10 built-in render modes; changing it at runtime immediately swaps the painter and triggers a repaint.

Toolbox icon: 🎛️
Category: Beep Widgets → Input Controls
Default size: 240 × 80
Namespace: TheTechIdea.Beep.Winform.Controls.Widgets

Key Features

🎛️ Ten Input Styles

From a simple toggle to a full range-selector — one control, ten behaviours.

✅ Strongly-Typed Values

ToggleValue, SliderValue, RangeValue, DateValue, NumberValue models carry all state.

🔔 ValueChanged Event

Universal ValueChanged event fires regardless of style; Data carries new value.

🎨 Theme Integration

Button, checkbox, and input colours all default to active theme tokens.

🚫 IsEnabled

Disabled state can be toggled at runtime; painters render the greyed-out style.

🖱️ OptionSelected

Dropdown and ButtonGroup fire OptionSelected with the chosen option string.

Style Variants (10)

Style ValueDescription
ToggleSwitchAnimated on/off toggle with label.
SliderHorizontal range slider with min/max labels.
DropdownFilterStyled dropdown for list filtering.
DatePickerDate-selection control with calendar pop-out.
SearchBoxSearch input with magnifier icon and suggestion support.
ButtonGroupRadio-style grouped button selection.
CheckboxGroupMultiple checkbox list with individual labels.
RangeSelectorDual-handle range selector for min/max input.
ColorPickerColour swatch picker with custom color option.
NumberSpinnerNumeric up/down spinner with typed input.

Properties

PropertyTypeDefaultDescription
StyleControlWidgetStyleToggleSwitchSelects the input control painter.
Titlestring"Control Title"Label drawn above or beside the control.
IsEnabledbooltrueEnable/disable the interactive control.
ShowLabelbooltrueShow/hide the title label.
ToggleValueToggleValue(IsOn=false)Toggle state for ToggleSwitch style.
SliderValueSliderValue(Value=50)Slider position for Slider style.
RangeValueRangeValue(Min=0,Max=100)Range handles for RangeSelector style.
DateValueDateValue(DateTime.Now)Selected date for DatePicker style.
NumberValueNumberValue(Value=0)Current number for NumberSpinner style.
OptionsList<string>[Option 1…]List of options for Dropdown and ButtonGroup.
SelectedOptionstring""Currently selected option string.
SearchTextstring""Current search query text.
CheckboxOptionsList<CheckboxOption>(3 items)Options list for CheckboxGroup.

Inherits all BaseControl properties (Border, Padding, Theme colors, etc.).

Events

EventArgs TypeDescription
ValueChangedBeepEventDataArgsFired when the control value changes. Data contains new value.
ControlClickedBeepEventDataArgsFired on any click within the control area.
OptionSelectedBeepEventDataArgsFired when an option is selected (Dropdown, ButtonGroup, Checkbox). Data contains selected option.

Basic Usage

// Toggle switch
var toggle = new BeepControlWidget
{
    Style      = ControlWidgetStyle.ToggleSwitch,
    Title      = "Dark Mode",
    ToggleValue = { IsOn = false },
    Size       = new Size(200, 60)
};

// Dropdown filter
var dropdown = new BeepControlWidget
{
    Style          = ControlWidgetStyle.DropdownFilter,
    Title          = "Filter by Status",
    Options        = new List { "All", "Active", "Inactive", "Pending" },
    SelectedOption = "All",
    Size           = new Size(220, 70)
};
this.Controls.Add(toggle);
this.Controls.Add(dropdown);

Event Handling

toggle.ValueChanged += (s, e) =>
{
    bool isOn = (bool)e.Data;
    ApplyDarkMode(isOn);
};

dropdown.OptionSelected += (s, e) =>
{
    string selected = (string)e.Data;
    FilterGrid(selected);
};

Best Practices

  • Set Style before adding the widget to the form to avoid double repaints.
  • Adjust Size to fit your layout — defaults are minimum comfortable sizes.
  • Read BeepEventDataArgs.Data in event handlers for context-specific click data.
  • Call Invalidate() after updating data properties to trigger a repaint.
  • Let theme colors flow from BeepStyling.CurrentTheme — avoid overriding color properties unless customization is explicitly desired.