Overview

BeepFormWidget 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 → Forms
Default size: 360 × 280
Namespace: TheTechIdea.Beep.Winform.Controls.Widgets

Key Features

📝 Ten Form Styles

From compact inline to multi-step wizard — every form layout covered.

✅ Validation Display

ValidatedInput and ValidationPanel render per-field error messages.

🔢 FormStep

FormStep style integrates with BeepNavigationWidget WizardSteps for multi-step flows.

📋 FormSummary

Read-only summary style for review-before-submit screens.

🎨 Theme tokens

ValidColor, InvalidColor, and AccentColor default to active theme tokens.

⭐ Required Indicators

ShowRequired renders asterisks on required fields automatically.

Style Variants (10)

Style ValueDescription
FieldGroupGrouped set of related labelled input fields.
ValidationPanelForm section with live validation state indicators.
FormSectionTitled section dividing a long form into logical parts.
InputCardSingle-input styled card — ideal for prominent single fields.
FormStepOne step in a multi-step form with step number and title.
FieldSetTraditional HTML-style fieldset with legend.
InlineFormHorizontal side-by-side label/input layout.
CompactFormSpace-efficient stacked layout for dense UIs.
ValidatedInputSingle input with inline validation message below.
FormSummaryRead-only summary of submitted form data.

Properties

PropertyTypeDefaultDescription
StyleFormWidgetStyleFieldGroupSelects the form layout painter.
Titlestring"Form Widget"Section or card heading.
Subtitlestring"Data Entry"Secondary sub-heading.
Descriptionstring""Helper text below the title.
FieldsList<FormField>(empty)Form fields. Each FormField has Label, Value, Type, IsRequired, IsValid, ErrorMessage.
IsValidbooltrueOverall form validity state.
ShowRequiredbooltrueShow asterisks on required fields.
ShowValidationbooltrueShow validation icons/messages.
AccentColorColor(theme primary)Active/focused field border colour.
ValidColorColor(theme success)Border/icon colour for valid fields.
InvalidColorColor(theme error)Border/icon colour for invalid fields.

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

Events

EventArgs TypeDescription
FieldClickedBeepEventDataArgsFired when a field area is clicked. Data contains FormField.
SubmitClickedBeepEventDataArgsFired when a submit button (if rendered) is clicked.
FieldChangedBeepEventDataArgsFired when a field value changes. Data contains FormField with new value.

Basic Usage

var form = new BeepFormWidget
{
    Style    = FormWidgetStyle.ValidationPanel,
    Title    = "User Registration",
    Fields   = new List
    {
        new FormField { Label = "First Name", Value = "", IsRequired = true  },
        new FormField { Label = "Last Name",  Value = "", IsRequired = true  },
        new FormField { Label = "Email",      Value = "", IsRequired = true,
                        IsValid = false, ErrorMessage = "Enter a valid email" },
        new FormField { Label = "Phone",      Value = "", IsRequired = false },
    },
    Size = new Size(380, 280)
};
this.Controls.Add(form);

Event Handling

form.FieldClicked += (s, e) =>
{
    var field = (FormField)e.Data;
    FocusNativeInput(field.Label);
};

form.SubmitClicked += (s, e) => ValidateAndSubmit();

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.