How to return value to a DateTimePicker? W#

2

I want to return data from a DataGridView to a DataTimePicker so I can change this data and save it again, but I'm having a hard time doing this because DataTimePicker does not accept value type.

private void btnAlterar_Click(object sender, EventArgs e)
{
    FrmCadCliente frmcadcliente = new FrmCadCliente();
    frmcadcliente.Show();

    frmcadcliente.txtID.Text = pacientes_TCCDataGridView.SelectedRows[0].Cells[0].Value.ToString();
    frmcadcliente.txtNome.Text = pacientes_TCCDataGridView.SelectedRows[0].Cells[1].Value.ToString();
    frmcadcliente.txtCPF.Text = pacientes_TCCDataGridView.SelectedRows[0].Cells[2].Value.ToString();
    frmcadcliente.txtRG.Text = pacientes_TCCDataGridView.SelectedRows[0].Cells[3].Value.ToString();
    frmcadcliente.cbxSexo.Text = pacientes_TCCDataGridView.SelectedRows[0].Cells[4].Value.ToString();
    frmcadcliente.dtpData.Text = pacientes_TCCDataGridView.SelectedRows[0].Cells[5].Value.ToString();
}

The error happens on this last line in Value

    
asked by anonymous 10.11.2016 / 18:23

1 answer

3

You can try the following:

frmcadcliente.dtpData.Value = Convert.ToDateTime(pacientes_TCCDataGridView.SelectedRows[0].Cells[5].Value.ToString());
    
10.11.2016 / 19:44