BB84.WinForms.Extensions 6.0.1130

dotnet add package BB84.WinForms.Extensions --version 6.0.1130
                    
NuGet\Install-Package BB84.WinForms.Extensions -Version 6.0.1130
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BB84.WinForms.Extensions" Version="6.0.1130" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BB84.WinForms.Extensions" Version="6.0.1130" />
                    
Directory.Packages.props
<PackageReference Include="BB84.WinForms.Extensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BB84.WinForms.Extensions --version 6.0.1130
                    
#r "nuget: BB84.WinForms.Extensions, 6.0.1130"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BB84.WinForms.Extensions@6.0.1130
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BB84.WinForms.Extensions&version=6.0.1130
                    
Install as a Cake Addin
#tool nuget:?package=BB84.WinForms.Extensions&version=6.0.1130
                    
Install as a Cake Tool

net472 net481 net100

BB84.WinForms.Extensions

Specialized extension methods for Windows Forms controls, focusing on simplified data binding. All binding methods follow the same fluent With*Binding(dataSource, dataMember) convention and return the control instance so calls can be chained.

🧰 Usage

Control extensions

ControlExtensions targets the base Control class and is therefore available on every WinForms control.

textBox1
    .WithTextBinding(vm, nameof(vm.Name))
    .WithEnabledBinding(vm, nameof(vm.IsEditable))
    .WithVisibleBinding(vm, nameof(vm.IsVisible))
    .WithTagBinding(vm, nameof(vm.Tag));

ButtonBase extensions

ButtonBaseExtensions adds ICommand binding and data-source–based command binding for Button, CheckBox, RadioButton, and any other ButtonBase-derived control.

// Bind an ICommand directly — wires Click and CanExecuteChanged automatically
saveButton.WithCommandBinding(viewModel.SaveCommand);

// Bind a command property from a data source (.NET 5+ targets)
saveButton.WithCommandBinding(viewModel, nameof(viewModel.SaveCommand));

// Bind a command parameter from a data source (.NET 5+ targets)
saveButton.WithCommandParameterBinding(viewModel, nameof(viewModel.CommandParameter));

CheckBox extensions

checkBox1
    .WithCheckedBinding(vm, nameof(vm.IsSelected))
    .WithCheckStateBinding(vm, nameof(vm.CheckState))
    .WithCheckAlignBinding(vm, nameof(vm.Alignment));

ComboBox extensions

comboBox1
    .WithDataSourceBinding(categories)                          // set items
    .WithDisplayMember(nameof(Category.Name))
    .WithValueMember(nameof(Category.Id))
    .WithSelectedItemBinding(vm, nameof(vm.SelectedCategory))
    .WithSelectedIndexBinding(vm, nameof(vm.SelectedIndex));

DataGrid / DataGridView extensions

dataGrid1.WithDataSourceBinding(dataTable);
dataGridView1.WithDataSourceBinding(bindingList);

DateTimePicker extensions

dateTimePicker1
    .WithValueBinding(vm, nameof(vm.SelectedDate))
    .WithCheckedBinding(vm, nameof(vm.HasDate));

FlagsCheckBox control

FlagsCheckBox is a composite user control that renders one CheckBox per non-zero flag value of a [Flags] enum and keeps a SelectedValue property in sync. Checking a box adds its flag to the selection, unchecking removes it, and clearing the last one falls back to the zero-valued flag.

// Fluent configuration
flagsCheckBox1
    .WithDisplayName()                                  // use DisplayAttribute.Name for labels
    .WithFlowDirection(FlowDirection.TopDown)
    .WithSelectedValueBinding(vm, nameof(vm.Permissions));

// Or use description attribute labels
flagsCheckBox1.WithDescriptionName();

// Custom label resolver
flagsCheckBox1.WithDisplayNameResolver(e => e.ToString().ToUpper());

FlagsRadioButton control

FlagsRadioButton renders one radio button per non-zero flag. AutoCheck is disabled, so a click toggles the flag it carries instead of clearing the other buttons — the selection accumulates the same way it does for FlagsCheckBox, only the visual style differs.

flagsRadioButton1
    .WithDisplayName()
    .WithFlowDirection(FlowDirection.LeftToRight)
    .WithSelectedValueBinding(vm, nameof(vm.AccessLevel));

FlagsControlBase

Both controls derive from FlagsControlBase, which owns the enum validation, the selection state, the bit arithmetic and the flow layout panel. Derive from it to add a control with a different button style; the five protected members to implement are CreateButton, AttachToggleHandler, GetChecked, SetChecked and ComputeNewBits.

ComputeNewBits receives the checked state as a bool, not the button, so an implementation never has to reach back into the control to do its bit arithmetic:

protected override long ComputeNewBits(long currentBits, long flagBits, bool isChecked)
    => isChecked ? currentBits | flagBits : currentBits & ~flagBits;

The fluent methods shown above come from FlagsControlExtensions and are generic over the control type, constrained to FlagsControlBase. A control derived from the base gets all of them without a line of extra code, and a chain keeps the concrete type it started with.

The enum bound to either control must define a zero-valued flag, which represents "nothing selected"; assigning a type without one throws an ArgumentException. Enums with an underlying type of ulong are not supported and throw an ArgumentException as well.

ListBox extensions

listBox1
    .WithDataSourceBinding(items)
    .WithSelectedItemBinding(vm, nameof(vm.SelectedItem))
    .WithSelectedIndexBinding(vm, nameof(vm.SelectedIndex));

ListControl extensions

ListControlExtensions targets the base ListControl class (ComboBox, ListBox, and any derived type).

comboBox1
    .WithDataSourceBinding(items)
    .WithDisplayMember(nameof(Item.Label))
    .WithValueMember(nameof(Item.Id))
    .WithSelectedValueBinding(vm, nameof(vm.SelectedId));

// Populate from an enum type
comboBox1.WithEnumeratorBinding(MyEnum.Default);

MonthCalendar extensions

monthCalendar1.WithSelectionRangeBinding(vm, nameof(vm.DateRange));

NumericUpDown extensions

numericUpDown1
    .WithValueBinding(vm, nameof(vm.Count))
    .WithMinimumBinding(vm, nameof(vm.MinCount))
    .WithMaximumBinding(vm, nameof(vm.MaxCount))
    .WithIncrementBinding(vm, nameof(vm.Step))
    .WithDecimalPlacesBinding(vm, nameof(vm.Precision));

PictureBox extensions

pictureBox1.WithImageBinding(vm, nameof(vm.Photo));

ProgressBar extensions

progressBar1.WithValueBinding(vm, nameof(vm.Progress));

RadioButton extensions

radioButton1.WithCheckedBinding(vm, nameof(vm.IsOptionA));

ScrollBar extensions

hScrollBar1.WithValueBinding(vm, nameof(vm.ScrollPosition));
vScrollBar1.WithValueBinding(vm, nameof(vm.ScrollPosition));

ToolStripItem extensions

Available on .NET 10 and later. Targets ToolStripButton, ToolStripMenuItem, and any other ToolStripItem-derived class.

toolStripButton1
    .WithEnabledBinding(vm, nameof(vm.CanSave))
    .WithTextBinding(vm, nameof(vm.SaveLabel))
    .WithVisibleBinding(vm, nameof(vm.ShowSave));

TrackBar extensions

trackBar1.WithValueBinding(vm, nameof(vm.Volume));

📖 Documentation

The complete API documentation can be found here.

Product Compatible and additional computed target framework versions.
.NET net10.0-windows7.0 is compatible. 
.NET Framework net472 is compatible.  net48 was computed.  net481 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.0.1130 94 11/30/2026
5.0.1118 159 11/18/2026
5.0.1027 209 10/27/2026
5.0.1020 133 10/20/2026
5.0.916 218 9/16/2026
5.0.823 206 8/23/2026
5.0.810 165 8/10/2026
4.6.803 200 8/3/2026
4.6.724 167 7/24/2026
4.6.625 212 6/25/2026
4.4.610 184 6/10/2026
4.3.603 192 6/3/2026
4.3.520 230 5/20/2026
4.3.428 212 4/28/2026
4.3.420 185 4/20/2026
4.3.319 273 3/19/2026
4.3.222 187 2/22/2026
4.3.214 180 2/14/2026
4.2.122 204 1/22/2026
4.0.1202 817 12/2/2025
Loading failed