Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DateTimePicker Problem

DateTimePicker Problem

Scheduled Pinned Locked Moved C#
helpalgorithmsperformancequestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    drey1
    wrote on last edited by
    #1

    I put a question about this control yesterday, but unfortunatelly i could not get a solution. So i change the flow of my program, but I still have one problem. the DateTimePicker.valuechanged event executes twice... I ask the other programmers here and not one knows why this control behives like this. So maybe someone have an answer. (searching the net i found two programmers that created new threads to resolve the problem, but that does not work for me, because I need the return from the "IsValid":confused: ). Code sample: bool b = true; //the code below does not work because the second time around the value still //the original value in memory if(((DateTimePicker)sender).Tag.ToString() == ((DateTimePicker)sender).Value.ToString()) return; this.Cursor = Cursors.WaitCursor; if(isValid(sender)) { tToDate.MinDate = tFromDate.Value; BindTimecard(tFromDate.Value,tToDate.Value); ((DateTimePicker)sender).Tag = ((DateTimePicker)sender).Value; } private bool IsValid(object sender, object r) { if(objdsIO.TimeCard.GetErrors().Length > 0) { string msg = "Please, Delete or Fix Records in Error, before Proceding!"; MessageBoxButtons button = MessageBoxButtons.OK; MessageBoxIcon icon = MessageBoxIcon.Error; MessageBox.Show(this,msg,"Error",button,icon); ((DateTimePicker)sender).ValueChanged -=new EventHandler(TimeDate_ValueChanged); ((DateTimePicker)sender).Value = DateTime.Parse(((DateTimePicker)sender).Tag.ToString()); ((DateTimePicker)sender).ValueChanged +=new EventHandler(TimeDate_ValueChanged); return false; } return true; } thank you for your help!

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups