How to populate comboBox in windows form c#

ComboBox is a collection, in which we can take Text as well as value of the text. After array, developer designed comboBox or DropDownList because array contains one attribute of object, its does not take two value at a time. Suppose you want to store employee name and age into memory. Where we would not use array. Here we will bind the comboBox in different manner likeMethod-1 : Bind ComboBox from dataset and datatable using ADO.NETMethod-2 : Bind ComboBox using Entity framework.

Method-1

I have a database table like Students, which take some value. The Data View of table, which is stored in database.

Method-2

If you want to bind combobox using entity framework or you can say strong model binding, just follow my steps.Step-1 : One class, which name as "Student.cs", which works as database table.

using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace WindowsFormsApplication10{ public class Student { public int Id { get; set; } public string name { get; set; } }}
In this class we are taking two member first is Id and second is name.Step-2 : Take another class, which name as "DataContext", which is used for creating database also used for inserting table in it. Look like