Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I'm trying to assign a dateTimePicker control to the datagridview cell as shown in this image


I find a solution similar to this problem in this site: http://www.c-sharpcorner.com/UploadFile/0f68f2/embedding-calendar-datetimepicker-control-into-datagridvie586/

But in this proposal it uses this slice of code to assign control:

C#
oDateTimePicker = new DateTimePicker();

      //Adding DateTimePicker control into DataGridView
      dataGridView1.Controls.Add(oDateTimePicker);


What I have tried:

While I use a datagridview linked with a database and makes a datatable path

C#
 ListeSeance = BLL.BLSeance.GetDateseance(numerofiche);
 datagridview.ColumnCount = ListeSeance.dt.Rows.Count;
for (int k = 0; k < ListeSeance.dt.Rows.Count; k++)
            {
 
 datagridview.Rows[0].Cells[k].Value = ListeSeance.dt.Rows[k][0].ToString();
}


Datagridview.Rows [0] .Cells [i] .Value = oDateTimePicker displays an error. is there a solution ?
Posted
Comments
Jawad Ahmed Tanoli 24-Nov-16 7:04am    
what error it display you
abboudi_ammar 24-Nov-16 10:21am    
this is the code which i inserted:
for (int k = 0; k < ListeSeance.dt.Rows.Count; k++)
{


DateTimePicker seancepicker = new DateTimePicker();

DGVabsence.Rows[0].Cells[k].Value = seancepicker;
}

and that show me in the cell of dataGridView System.Windows.Forms.DateTimePicker, Value
Jawad Ahmed Tanoli 28-Nov-16 5:01am    
you should try like this
DateTimePicker seancepicker = new DateTimePicker();

DGVabsence.Rows[0].Cells[k].Value = seancepicker.Value;

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