1
Answer

Assign the dateTimePicker control to the datagridView cell

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:
 
  1. oDateTimePicker = new DateTimePicker();    
  2.   
  3.       //Adding DateTimePicker control into DataGridView     
  4.       dataGridView1.Controls.Add(oDateTimePicker);  
 While I use a datagridview linked with a database and makes a datatable path
 
  1.    
  2.  ListeSeance = BLL.BLSeance.GetDateseance(numerofiche);  
  3.  datagridview.ColumnCount = ListeSeance.dt.Rows.Count;  
  4. for (int k = 0; k < ListeSeance.dt.Rows.Count; k++)  
  5.             {  
  6.    
  7.  datagridview.Rows[0].Cells[k].Value = ListeSeance.dt.Rows[k][0].ToString();  
  8. }  
 Datagridview.Rows [0] .Cells [i] .Value = oDateTimePicker displays an error. is there a solution ?
 
Answers (1)