By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,805 Members | 1,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,805 IT Pros & Developers. It's quick & easy.

DaitTimePicker Events

P: 6
Good evening. My name is Don. I tried the intrduction page but couldn't get it to accept my message.
I am developing software in VB 2005, and I am looking for quidance in using the datetimepicker control. I have code in the datechanged event to retrieve data from the database. The code works fine. The problem I have is that the code executes when I change the calendar month. I am looking for an event that executed before the datechanged event, so that I can set some kind of flag that can be queried in the datechanged event to supress the code there.
May 7 '07 #1
Share this Question
Share on Google+
4 Replies


Dököll
Expert 100+
P: 2,364
Good evening. My name is Don. I tried the intrduction page but couldn't get it to accept my message.
I am developing software in VB 2005, and I am looking for quidance in using the datetimepicker control. I have code in the datechanged event to retrieve data from the database. The code works fine. The problem I have is that the code executes when I change the calendar month. I am looking for an event that executed before the datechanged event, so that I can set some kind of flag that can be queried in the datechanged event to supress the code there.
Hello, Don!

Can you do this in form load?

You should add your code so members here can see it, the possibilities are endless beyond that.

We'll read about it and see what I can do meanwhile, Don.

In a bit!

Dököll
May 8 '07 #2

Expert 5K+
P: 8,434
...The problem I have is that the code executes when I change the calendar month.
Could you explain in a little more detail what you mean by this, please?

Also, have you tried playing around with the other events, to see when they are triggered? I’m using VB6 and I believe the events are a little different, but the Click event might be worth a look.
May 8 '07 #3

P: 6
Hello, Don!

Can you do this in form load?

You should add your code so members here can see it, the possibilities are endless beyond that.

We'll read about it and see what I can do meanwhile, Don.

In a bit!

Dököll
I am performing the event in the form load, because the load does not trigger the DateChanged event and I want to get the data on the load. The problem is that the DateChanged event is triggered when I click the calendar to change the month. I am looking for a way to not go out to the database before the month changes. The DateChanged event is triggered Two times, once before the date changes, and one after. I do want the second occurrence of DateChanged to execute, so I can check the new date, but I want to set up a flag to stop the DateChanged event from executing before the month changes. Even if I find an event that happens before the DateChanged event, How do I identify that the Arrow has been clicked instead of a Date in the datetimepicker?
May 8 '07 #4

Dököll
Expert 100+
P: 2,364
I am performing the event in the form load, because the load does not trigger the DateChanged event and I want to get the data on the load. The problem is that the DateChanged event is triggered when I click the calendar to change the month. I am looking for a way to not go out to the database before the month changes. The DateChanged event is triggered Two times, once before the date changes, and one after. I do want the second occurrence of DateChanged to execute, so I can check the new date, but I want to set up a flag to stop the DateChanged event from executing before the month changes. Even if I find an event that happens before the DateChanged event, How do I identify that the Arrow has been clicked instead of a Date in the datetimepicker?
Sounds pretty fancy there, diston52...

Still, you did not add your code. I am also using VB 6, so I can only offer information and ideas. I did pull up a code on specific to DateTimePicker, sett your eyes on it, see if you can strip it for your own use. Also go to the link to truly see what it does. Bare in mind I am only a messenger, you'll need to add your code for skilled/trained eyes here to see what's a miss:

Gathered through: http://www.devage.com/Wiki/ViewArtic...grid&version=0

Go towards mid portion of the page to see this code

Expand|Select|Wrap|Line Numbers
  1.  
  2. public class DateTimePicker : EditorControlBase
  3. {
  4.     public DateTimePicker():base(typeof(System.DateTime))
  5.     {
  6.     }
  7.  
  8.     protected override Control CreateControl()
  9.     {
  10.         System.Windows.Forms.DateTimePicker l_dtPicker = new System.Windows.Forms.DateTimePicker();
  11.         l_dtPicker.Format = DateTimePickerFormat.Short;
  12.         return l_dtPicker;
  13.     }
  14.  
  15.     public new System.Windows.Forms.DateTimePicker Control
  16.     {
  17.         get{return (System.Windows.Forms.DateTimePicker)base.Control;}
  18.     }
  19.     public override void SetEditValue(object editValue)
  20.     {
  21.         if (editValue is DateTime)
  22.             Control.Value = (DateTime)editValue;
  23.         else if (editValue == null)
  24.             Control.Value = DateTime.Now;
  25.         else
  26.             throw new SourceGridException("Invalid edit value, expected DateTime");
  27.     }
  28.     public override object GetEditedValue()
  29.     {
  30.         return Control.Value;
  31.     }
  32. }
  33.  
  34.  
You will need to do a lot of work, it seems, to get what you need out of it. Keep asking questions, just in case...

Good luck!
May 9 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.