We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DateTimePickerExt Focused

I am working with the ValueChanged event of the DateTimePickerExt control and am trying to raise a dirty flag when the data has changed. Unfortunately the Focused property is never True when the user selects a date from the calendar control. Is there a way that I can only set my flag if the user made the change vs. data loading into the control? The event triggers when my data is populated, but I don''t want that to trigger my flag. Here is the code that I have inside the event. if (dtp.Focused) { // When a date picker control is changed, flag dirty. toggleDirtyFlag(true); }

3 Replies

AD Administrator Syncfusion Team April 13, 2004 08:49 PM UTC

Hi, Thanks for your feedback. If you look closely the Windows Forms DateTimePicker control too behaves the same way. Our DateTimePickerExt control was modelled after the Windows Forms DateTimePicker control, and hence we retained this behavior for consistency purposes. Could you please let us know why do you check if the DateTimePickerExt has focus in your code? The ValueChanged event is fired only when the value is changed through the drop down calendar and not when it is keyed in from the keyboard. The ValueChanged event does not fire when the application is loaded. Let me know if I have understood your problem correctly. We appreciate your interest in Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.


JH Jamie Hill April 13, 2004 09:08 PM UTC

What I need is to know when a user changes the date in the control. If through code, I do: dtp.Value = Now.ToShortDateString(); the ValueChanged event will fire. I just need to know when the event is firing as a result of the user making a change, or when it is changed through code. I had noticed that the event does not fire when you type in the control. How do I handle this? I don''t see a TextChanged type event either. Thanks, JH >Hi, > >Thanks for your feedback. If you look closely the Windows Forms DateTimePicker control too behaves the same way. Our DateTimePickerExt control was modelled after the Windows Forms DateTimePicker control, and hence we retained this behavior for consistency purposes. > >Could you please let us know why do you check if the DateTimePickerExt has focus in your code? The ValueChanged event is fired only when the value is changed through the drop down calendar and not when it is keyed in from the keyboard. The ValueChanged event does not fire when the application is loaded. Let me know if I have understood your problem correctly. We appreciate your interest in Syncfusion products. > >Regards, >Guru Patwal >Syncfusion, Inc.


AD Administrator Syncfusion Team April 14, 2004 01:36 PM UTC

Hi JH, When you wish to set the DateTimePicker`s value you could use the SetDTPValue method (shown below) such that it sets the value and sets the bool flag codeSet to true, i.e., that the next event fired by the DateTimePicker will be ignored as conditioned in the event handler. bool codeSet = false; private void SetDTPValue(DateTime dateTime) { this.dateTimePickerAdv1.Value = dateTime; codeSet = true; } private void dateTimePicker1_ValueChanged(object sender, System.EventArgs e) { if(codeSet) { codeSet = false; return; } else { // This means that the control`s Value was changed by the user in code. // When a DateTimePicker control''s value is changed, dirty flag. toggleDirtyFlag(true); } } Please try this and let me know if this meets your requirements. Regards, Guru Patwal Syncfusion, Inc.

Loader.
Live Chat Icon For mobile
Up arrow icon