The Form gets stuck/Locked when I click the datetimepicker

Asked

Viewed 111 times

3

I’m developing an application and I’ve done 90%, but I have a problem with the datetimepicker control.

Normally its format is long, but I had to change to 'team' and enabled the ShowUpDown as true.

When I click on the control the form gets stuck and nothing else works and does not close.

So I have to close in Windows Task Manager or stop debugging.

How can I fix this?

There is no event associated, I just, in graphic mode, edit the time of the visitor’s departure and to 12:45:00 for example, then click the update button taking the value of the control through the property nameObject.Value.Timeofday; which is the property of Timespan that I need to store in the database.

The problem is that when I touch the contorle, the other contorles not only work, nor the update button responds to the click, but the control in question continues allowing changing time, minute and second, it’s like I have to take it out of editing mode or stop some event that it creates.


Follow my form code, just watch out for the update button method:

using System;
using System.Windows.Forms;
using ObjetoTransferencia.ControleVisitante;
using RegrasDeNegocio.CRUD;

namespace Intragh.Portaria
{
    public partial class FrmControleVisitante : Form
    {
        private readonly ControleVisitanteCRUD _controleVisitanteCrud;
        public FrmControleVisitante()
        {
            InitializeComponent();
            _controleVisitanteCrud = new ControleVisitanteCRUD();
        }

        private void FrmControleVisitante_Load(object sender, EventArgs e)
        {
            controleVisitanteBindingSource.DataSource = _controleVisitanteCrud.GetAll();
        }

        private void btnNovo_Click(object sender, EventArgs e)
        {
            FrmControleVisitanteCadastrar frmControleVisitanteCadastrar = new FrmControleVisitanteCadastrar();
            frmControleVisitanteCadastrar.ShowDialog();
            controleVisitanteBindingSource.DataSource = _controleVisitanteCrud.GetAll();
        }

        private void btnAtualizar_Click(object sender, EventArgs e)
        {
            try
            {
                var controleVisitante = controleVisitanteDataGridView.SelectedRows[0].DataBoundItem as ControleVisitante;

                if (controleVisitante != null)
                {
                    controleVisitante.ControleId = Convert.ToInt32(controleIdTextBox.Text);
                    controleVisitante.HoraSaida = horaEntradaDateTimePicker.Value.TimeOfDay;
                    controleVisitante.Observacao = observacaoTextBox.Text;

                    _controleVisitanteCrud.Atualizar(controleVisitante);
                }
                controleVisitanteBindingSource.DataSource = _controleVisitanteCrud.GetAll();

            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
    }
}

  • There are events attached to this control?

  • 3

    put the code of your young form

  • when the screen is locked, pause the visual studio debugging to see which code was running

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.