Search code examples
c#visual-studio-2008datagridviewdatetimepicker

How to get date values form grid's cell to date time picker control in new form


How can we pass a grid cell's value to datetimepicker ? I have a grid with columns, in which one column store date values(YYYY-MM-DD) format. When I click edit button, selected row values need to be passed to new form and date value is need to be set of DateTimePicker control. Is this possible, if yes then how ?


Solution

  • This is what I need:

    DateTime dtBookPublishDate = DateTime.Parse (dgvBooksDetails.CurrentRow.Cells[5].Value.ToStrin());                                                                      
    myBookInformation.dtpBookPublishDateInfo.Value = DateTime.Parse(dtBookPublishDate.ToShortDateString());  
    

    where, frmBookInformation is sub form and currently Im on Main Form.