DateTimePicker never updates!

假装没事ソ 提交于 2019-12-04 00:24:43

One small hint with this trouble: my problem was that I had the DateTimePicker set to checked=false and (by mistake) ShowCheckbox=false; With this setup I could set to DTPicker whatever value I wanted, but it won't udate itself.

The standard diagnostic for a form not updating its visual appearance, but you seeing the property update with the debugger just fine is using the wrong form instance. Like this for example:

var frm = new Form1();  // Wrong!!
frm.UpdateBirthDay(user.BirthDay);

Diagnose this by altering your code like this:

dateTimePicker1.Value = user.BirthDay;
this.Show();   // <=== add this

My work around to update a stuborn DateTimePicker to display its current value and also update its related DataBindings is to toggle its .Enabled property.

myDateTimePicker.Enabled = !myDateTimePicker.Enabled;
myDateTimePicker.Enabled = !myDateTimePicker.Enabled;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!