Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table named 'test' in that have a column named 'fname'
and datadridview combobox column
i want column fname items should be add in datagridview every row's first cell
Posted

C#
DataGridViewComboBoxColumn dc = new DataGridViewComboboxColumn();
dc.DataSource = dt;
dc.ValueMember = "ID";
dc.TextMember = "Name";
 
DataGridView1.Columns.Add("ColumnName", dc);

where dt = datatable.
 
Share this answer
 
v2
Comments
Manas Bhardwaj 12-Jun-12 9:15am    
correct +5!
hit91 12-Jun-12 12:39pm    
thank u,
but i not using static values for that combobox.
combobox items should be come from sql table
Upniwesh 12-Jun-12 23:43pm    
at first you can retrieve data from SQL and store the data in Datatable dt......
Please refer:
ComboBox in DataGrid[^]

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcomboboxcolumn.aspx[^]
Demonstrates how to use a DataGridViewComboBoxColumn to aid in entering data into the TitleOfCourtesy column.
 
Share this answer
 
Comments
Manas Bhardwaj 12-Jun-12 9:15am    
5ed!
Prasad_Kulkarni 12-Jun-12 23:46pm    
Thank you Manas!
VJ Reddy 12-Jun-12 11:16am    
Good references. 5!
Prasad_Kulkarni 12-Jun-12 23:46pm    
Thank you VJ!

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