ListView Control Data Binding in C#.NET
Kettic ListView .NET control is capable of binding to data source to display those data. There are three properties available for the users to bind ListView to data, the DataSource, ShowMember, and ValueMember. The DataSource property is used to specify the data source that the ListView will be bound to, the ShowMember displays the specific data in a ListView, and the ValueMember returns the value of a ListView from the specific data.
How to Configure DataBinding Properties
The DataSource property can be configured either in the Properties windows or in the Smart Tag menu of Kettic ListView control. The following steps show how to the DataSource and ValueMember and ValueMember properties.
How to Customize Columns in ListView in C#.NET
After we bind the Kettic ListView control to a collection of business objects and choose the ViewType to be DetailsView, the columns will display the values of all the properties of the business objects. We can customize the column size, viability, and other properties by handling the CreateColumn event. The C# code below shows how to create columns in C#.NET.
How to Bind ListView to Data in C#.NET
The guide below shows how to bind a ListView component to a list of business objects in C#.NET project. We will create a business object first and the custom object will implement the ChangedINotifyProperty interface. After that, we can create a collection of our business objects by using the C# code below.
To bind the Kettic ListView control to this collection, we can simply configure the properties, DataSource, DisplayMember and ValueMember by using the C# code below.
After setting these properties, we will get the Kettic ListView populated with items that display the value Name property and the ID property of the business object returned as value. We can see them via opening an item for editing.
To extend the functionality of the case, we can handle the ItemDataBound event, which will be fired after assigning the ListViewDataItem an object from the data bound. We can access the data bound object properties in the event handler and assign an image to the item by using the C# code below.
|
UI Controlsfor Windows Forms .NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI DesignWinForms UI Controls WinForms Buttons UI Control WinForms Calendar UI ControlWinForms Carousel UI ControlWinForms Chart UI ControlWinForms Clock UI ControlCommandBar UI ControlWinForms Dock UI ControlDesktop Alert UI ControlDropDown List UI ControlWinForms Editor UI ControlForms and Dialogs UI ControlWinForms GridView UI ControlWinForms ListView UI ControlGet Started in C#ListView - View TypesListView - Design TimeAdd ColumnsAdd GroupsAdd ItemsListView - FeaturesItem Selection & SizingFilteringGroupingSortingListView - Data BindingPopulating with DataCheckbox & EditorCustom ItemsWinForms Menu UI ControlWinForms ComboBox UI ControlWinForms PageView UI ControlPanels and Labels UI ControlWinForms Panorama UI ControlWinForms PDFViewer UI ControlWinForms Property Grid UI ControlWinForms Ribbon UI ControlWinForms PivotGrid UI ControlWinForms RichTextBox UI ControlWinForms Rotator UI ControlWinForms Scheduler UI ControlWinForms Shortcuts UI ControlWinForms SpellChecker UI ControlWinForms Track & Status UI ControlWinForms TreeView UI ControlWinForms Wizard UI ControlWinForms Test UI ControlWinForms Theme UI Control |