Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to set a datagridview with a combo column that display table value from a database while form load...

Can any one help me

iam using following code for displaying data from DB table in datagridview


C#
private void edit_res_per_Load(object sender, EventArgs e)
     {
         mycon = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\ETMS\\ETMS\\ETMS\\etms.accdb");
         string query = "Select resid as ID, resname as Person_Name,resdesg as Designation, resdept as Department From resperson order By resid ";
         da = new OleDbDataAdapter(query, mycon);
         OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
         dt = new DataTable();
         da.Fill(dt);
         dgv1.AllowUserToAddRows = false;


         dgv1.DataSource = dt;
         dgv1.Columns[0].ReadOnly = true;



     }
Posted
Updated 28-Jun-11 0:31am
v2

1 solution

You can use the DataGridViewComboBoxColumn class - see here[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900