GridView Data Binding to Generic Lists in C#.NET
The Kettic DataGridView component is capable of binding to Generic Lists. The GirdView control is able to internally generate grid columns and recognize data for the business object properties which is bound to, so users of the GridView control need not to bind it to a list of simple types. The GridView control canât be bound to a List of integers for the integer type does not have data property. In this article, we are going through the process of binding GridView C#.NET component to a Generic List.
GridView Data Binding to Lists of Simple Types
The example below demonstrates how to bind the DataGridView C#.NET component to a collection of strings. Because the only string objects property is the Length property, so we will get a grid column which represents the length of strings. The following is the C# code for GridView data binding to list of simple types.
GridView Data Binding to Lists of Objects
The Kettic GridView component is capable of binding to Lists of objects that includes support data types. This is achieved by assigning the List to the DataSource property of the DataGriView control. In the example as following, we will define a MyObject C# class which will contains the integer and string property and create an array of MyObject in C# to initialize the array with objects. And then we will assign the array to the DataSource property.
C# code for GridView data binding to list of simple types
|
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 ControlGridView - Get Started in C#GridView - PropertiesGridView - ColumnGridView - RowGridView - CellsGridView - EditorsGridView - Context MenuConditional Custom Context MenuModify Default Context MenuGridView - Populating with DataData BindingBinding to Array and ArrayListBinding to Generic ListBinding to Binding ListBinding to DataTable / DataSetBinding to DataReaderBinding to Sub ObjectsBinding to XMLUnbound ModeUpdate DatabaseGridView - Hierarchical GridGridView - SelectionGridView - ScrollingGridView - SortingGridView - GroupingGridView - FilteringGridView - Expression EditorInsert/ Update/ Delete RecordsGridView - View DefinitionGridView - Exporting DataStyling and AppearanceGridView - LocalizationSave and Load LayoutGridView - Print SupportWinForms ListView UI ControlWinForms 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 |