BindingSource Component Sample
This sample demonstrates binding the BindingSource component to a Type.
The BindingSource component can bind to types as well as objects in memory. In this sample, a BindingSource is bound to the Flag
type, and the flagName
and flagImage
controls are bound to Flag
type's properties through the BindingSource.
For information about using the samples, see the following topics:
Security Note |
---|
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended. |
To build and run the sample using the command prompt
At the command prompt, navigate to the location where you saved the uncompressed sample files.
Navigate to one of the language-specific subdirectories under the BindingSourceSample directory.
Type msbuild to build the sample using the solution (.sln) file provided.
Type cd BindingSourceSample\bin\Debug to navigate to the location of the executable file.
Type BindingSourceSample.exe to run the sample.
To build and run the sample using Visual Studio
In Windows Explorer, navigate to the location where you saved the uncompressed sample files.
Navigate to one of the language-specific subdirectories under the BindingSourceSample directory.
Double-click the solution (.sln) file to open it in Visual Studio.
In Visual Studio, press F5 to build and run the sample.
To use BindingSourceSample
Click on the Add button to create a
Flag
object and add it to the BindingSource.Click on the < and > buttons to use the BindingSource to navigate through the BindingSource items. The
positionIndicator
TextBox control shows the position of the current BindingSource item as well as the BindingSource item count.
Demonstrates
Using a BindingSource component to bind Windows Forms controls to a data source.
Using a BindingSource component to bind to a Type.
See Also
Tasks
How to: Bind a Windows Forms Control to a Type
Reference
Panel
BindingSource
BindingNavigator
DataGridView
System.Collections.IList
System.ComponentModel.IBindingList
System.ComponentModel.IEditableObject