DaitTimePicker Events

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • diston52
    New Member
    • May 2007
    • 6

    DaitTimePicker Events

    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.
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by diston52
    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

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by diston52
      ...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.

      Comment

      • diston52
        New Member
        • May 2007
        • 6

        #4
        Originally posted by Dököll
        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?

        Comment

        • Dököll
          Recognized Expert Top Contributor
          • Nov 2006
          • 2379

          #5
          Originally posted by diston52
          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

          Code:
          public class DateTimePicker : EditorControlBase
          {
          	public DateTimePicker():base(typeof(System.DateTime))
          	{
          	}
          
          	protected override Control CreateControl()
          	{
          		System.Windows.Forms.DateTimePicker l_dtPicker = new System.Windows.Forms.DateTimePicker();
          		l_dtPicker.Format = DateTimePickerFormat.Short;
          		return l_dtPicker;
          	}
          
          	public new System.Windows.Forms.DateTimePicker Control
          	{
          		get{return (System.Windows.Forms.DateTimePicker)base.Control;}
          	}
          	public override void SetEditValue(object editValue)
          	{
          		if (editValue is DateTime)
          			Control.Value = (DateTime)editValue;
          		else if (editValue == null)
          			Control.Value = DateTime.Now;
          		else
          			throw new SourceGridException("Invalid edit value, expected DateTime");
          	}
          	public override object GetEditedValue()
          	{
          		return Control.Value;
          	}
          }
          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!
          Last edited by Dököll; May 9 '07, 01:03 AM. Reason: Added remark

          Comment

          Working...