Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello dear friends
I'm working with this code but I do not know the answer, do not take it?
Help me please

C#
var a = from p in db.tbl_Date

                    select p.day;

DataGridViewComboBoxColumn dgvCmb = new DataGridViewComboBoxColumn();

  dataGridView1.Columns.Add("Name", "myName");

            dataGridView1.Columns.Add("Numbers", "myNumbers");

            dataGridView1.Columns.Add("price", "Myprice");

dataGridView1.Columns.Add(dgvCmb);

dgvCmb.DataSource = a;
Posted
Comments
pradiprenushe 1-Apr-13 2:14am    
i think you should set data source to dgvCmb before adding dgvCmb to datagrid.

in last line try:
C#
dgvCmb.DataSource = a.ToArray();
 
Share this answer
 
Comments
mahdad sepahsalari 30-Mar-13 12:56pm    
Thanks for your answer but it did not work :(
Even here does not answer
dgvCmb.items.Add("Test");
Hi,

Try this



C#
<pre lang="HTML">// bind it
dgvCmb.DataSource = a.ToList();

Else 

foreach(var result in a)
{
dgvCmb.items.Add(result);

}
 
Share this answer
 
v2
Comments
mahdad sepahsalari 31-Mar-13 8:04am    
Thanks for your answer but it did not work :(

My Datagridview is not connected to the database.
A series of temporary data into a combobox that I will always be in one of his columns, but unfortunately does not show any item
But when the grid is connected to the database combobox that also displays the information correctly
please Help me!
C#
DataGridViewComboBoxColumn dgvCmb = new DataGridViewComboBoxColumn();
dgvCmb.Datasource = dt;//data table
dgvCmb.DisplayMember = "column1";//column to display
dgvCmb.ValueMember = "column2";//id column
dataGridView1.Columns.Add(dgvCmb, "myName");

Happy Coding!
:)
 
Share this answer
 
v2
The problem was solved Friends
""Enable Editing =true""
All the code that you said was true, I would just do it already
 
Share this answer
 
Use GridView's DataBound event..
 
Share this answer
 

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

  Print Answers RSS


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