BindingExtensions
Wisej.Web.Markup.BindingExtensions
Namespace: Wisej.Web.Markup
Assembly: Wisej.Framework (4.0.0.0)
Adds fluent markup extension methods to the Control class.
public class BindingExtensions
Methods
Bind<TComponent, TTargetProp, TSource>(component, targetProp, dataSource, sourceProp, formattingEnabled, updateMode, nullValue, formatString, formatProvider, parse, format)

Binds a specified property of a component to a property of a data source.
TTargetProp
The type of the target property on the component.
TSource
The type of the data source.
targetProp
An expression representing the target property on the component.
formatProvider
An object that provides culture-specific formatting information. Default is null
.
parse
A function to convert the data source value to the target property type. Default is null
.
format
A function to convert the target property value to the data source type. Default is null
.
Returns: TComponent. The component with the binding applied.
This method allows for complex data binding scenarios where custom parsing and formatting logic is required.
var component = new TextBox();
var dataSource = new { Value = 123 };
component.Bind(c => c.Text, dataSource, "Value", format: v => v.ToString());
Bind<TComponent, TSource>(component, targetProp, dataSource, sourceProp, formattingEnabled, updateMode, nullValue, formatString, formatProvider, parse, format)

Binds a specified property of a component to a data source property with optional formatting and conversion.
TSource
The type of the data source.
parse
A function to convert the data source value to the target property type. Default is null
.
format
A function to convert the target property value to the data source type. Default is null
.
Returns: TComponent. The component with the binding applied.
This method is useful for simple data binding scenarios where the target property and data source property types are compatible.
var component = new TextBox();
component.Bind("Text", dataSource, "Name");
Bind<TComponent, TSource>(grid, columnIndex, dataSource, sourceProp, parse, format)

Binds a specified column of the DataGridView to a data source.
TComponent
The type of the DataGridView component.
TSource
The type of the data source.
parse
Optional. A function to parse cell values. Default is null
.
format
Optional. A function to format cell values. Default is null
.
Returns: TComponent. The DataGridView with the specified column bound to the data source.
This method binds a column of the DataGridView to a specified property of the data source.
var grid = new DataGridView();
grid.Bind(0, dataSource, "PropertyName");
Bind<TComponent, TSource>(grid, columnIndex, dataSource, dataMember, sourceProp, parse, format)

Binds a specified column of the DataGridView to a data source with a data member.
TComponent
The type of the DataGridView component.
TSource
The type of the data source.
parse
Optional. A function to parse cell values. Default is null
.
format
Optional. A function to format cell values. Default is null
.
Returns: TComponent. The DataGridView with the specified column bound to the data source.
This method binds a column of the DataGridView to a specified property of the data source, using a data member.
var grid = new DataGridView();
grid.Bind(0, dataSource, "DataMember", "PropertyName");
Bind<TComponent, TSource>(grid, columnName, dataSource, sourceProp, parse, format)

Binds a specified column of the DataGridView to a data source using the column name.
TComponent
The type of the DataGridView component.
TSource
The type of the data source.
parse
Optional. A function to parse cell values. Default is null
.
format
Optional. A function to format cell values. Default is null
.
Returns: TComponent. The DataGridView with the specified column bound to the data source.
This method binds a column of the DataGridView to a specified property of the data source using the column name.
var grid = new DataGridView();
grid.Bind("ColumnName", dataSource, "PropertyName");
Bind<TComponent, TSource>(grid, columnName, dataSource, dataMember, sourceProp, parse, format)

Binds a specified column of the DataGridView to a data source with a data member using the column name.
TComponent
The type of the DataGridView component.
TSource
The type of the data source.
parse
Optional. A function to parse cell values. Default is null
.
format
Optional. A function to format cell values. Default is null
.
Returns: TComponent. The DataGridView with the specified column bound to the data source.
This method binds a column of the DataGridView to a specified property of the data source, using a data member and the column name.
var grid = new DataGridView();
grid.Bind("ColumnName", dataSource, "DataMember", "PropertyName");
Bind<TComponent, TSource>(grid, column, dataSource, sourceProp, parse, format)

Binds a specified DataGridViewColumn to a data source.
TComponent
The type of the DataGridView component.
TSource
The type of the data source.
parse
Optional. A function to parse cell values. Default is null
.
format
Optional. A function to format cell values. Default is null
.
Returns: TComponent. The DataGridView with the specified column bound to the data source.
This method binds a DataGridViewColumn to a specified property of the data source.
var grid = new DataGridView();
var column = grid.Columns[0];
grid.Bind(column, dataSource, "PropertyName");
Bind<TComponent, TSource>(grid, column, dataSource, dataMember, sourceProp, parse, format)

Binds a specified DataGridViewColumn to a data source with a data member.
TComponent
The type of the DataGridView component.
TSource
The type of the data source.
parse
Optional. A function to parse cell values. Default is null
.
format
Optional. A function to format cell values. Default is null
.
Returns: TComponent. The DataGridView with the specified column bound to the data source.
This method binds a DataGridViewColumn to a specified property of the data source, using a data member.
var grid = new DataGridView();
var column = grid.Columns[0];
grid.Bind(column, dataSource, "DataMember", "PropertyName");
Bind<TComponent, TSource>(listView, columnName, dataSource, sourceProp)

Binds a data source to a specified column in a ListView.
TComponent
The type of the ListView component.
TSource
The type of the data source.
Returns: TComponent. The ListView component with the data source bound to the specified column.
This method binds a data source to a specified column in a ListView by setting the column's display property name and assigning the data source to the ListView.
var listView = new ListView();
listView.Bind("ColumnName", dataSource, "SourceProperty");
Throws:
ArgumentException Thrown when the specified column name does not exist in the ListView.
Bind<TComponent, TSource>(listView, columnName, dataSource, dataMember, sourceProp)

Binds a data source to a specified column in a ListView with a specified data member.
TComponent
The type of the ListView component.
TSource
The type of the data source.
Returns: TComponent. The ListView component with the data source bound to the specified column and data member.
This method binds a data source to a specified column in a ListView by setting the column's display property name, assigning the data member, and then assigning the data source to the ListView.
var listView = new ListView();
listView.Bind("ColumnName", dataSource, "DataMember", "SourceProperty");
Throws:
ArgumentException Thrown when the specified column name does not exist in the ListView.
Bind<TComponent, TSource>(listView, column, dataSource, sourceProp)

Binds a data source to a specified column in a ListView.
TComponent
The type of the ListView component.
TSource
The type of the data source.
Returns: TComponent. The ListView component with the data source bound to the specified column.
This method binds a data source to a specified column in a ListView by setting the column's display property name and assigning the data source to the ListView.
var listView = new ListView();
var column = new ColumnHeader();
listView.Bind(column, dataSource, "SourceProperty");
Throws:
ArgumentNullException Thrown when the specified column is null.
Bind<TComponent, TSource>(listView, column, dataSource, dataMember, sourceProp)

Binds a data source to a specified column in a ListView with a specified data member.
TComponent
The type of the ListView component.
TSource
The type of the data source.
Returns: TComponent. The ListView component with the data source bound to the specified column and data member.
This method binds a data source to a specified column in a ListView by setting the column's display property name, assigning the data member, and then assigning the data source to the ListView.
var listView = new ListView();
var column = new ColumnHeader();
listView.Bind(column, dataSource, "DataMember", "SourceProperty");
Throws:
ArgumentNullException Thrown when the specified column is null.
Last updated
Was this helpful?