2

Estou querendo retornar dados de um DataGridView para um DataTimePicker para que eu possa fazer a alteração deste dado e salva-lo novamente, mas estou com uma dificuldade em fazer isso pois o DataTimePicker não aceita tipo value.

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();
}

O erro acontece nesta ultima linha em Value

1 Resposta 1

3

Você pode tentar fazer o seguinte:

frmcadcliente.dtpData.Value = Convert.ToDateTime(pacientes_TCCDataGridView.SelectedRows[0].Cells[5].Value.ToString());
2
  • NOSSA! muito obrigado por responder, olha deu certo sim!! eu só mudei frmcadcliente.dtpData.Text para frmcadcliente.dtpData.Value e funcionou perfeitamente muito obrigado! 10/11/2016 às 18:51
  • @GabrielArruda, Disponha! 10/11/2016 às 19:12

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .