Welcome to the Xceed Community | Help
Community Search  
More Search Options

WinDatePicker's NullDateString

Sort Posts: Previous Next
  •  05-03-2009, 9:14 PM Post no. 20683

    WinDatePicker's NullDateString

    I have set the NullDateString to empty but somehow when I am showing the form where the control (WinDatePicker) is located it is still showing (null), I would want to be empty instead of (null). I somehow noticed that it only gets empty when I have focused and remove the focus on the control.

    Is there a way that I could automatically set it to empty when the form is displayed?

    Thank you so much

  •  05-04-2009, 4:33 PM Post no. 20709 in reply to 20683

    Re: WinDatePicker's NullDateString

    We do not reproduce this on our side.  When we set NullDateString to empty, it works fine.

    e.g.:

          winDatePicker1.NullDateString = string.Empty;

    If you have a code snippet that reproduce this, supply it so we can investigate it further.


    André
    Software Developer
    Xceed Software Inc.
  •  05-05-2009, 6:32 PM Post no. 20740 in reply to 20709

    Re: WinDatePicker's NullDateString

    I have already tried setting it when in the form's load event and also by just deleting the default "(null)" in the properties window to no avail. Is there any other setting that could affect the NullDateString?

    And also, what is the surefire way of testing if the WinDatePickers date is a null? For now I am testing it against the NullDate like the following:

    if (date1.Value != date1.NullDate)
      testClass.Date1 = date1.Value;
    else
      testClass.Date1 = null;

    Is there a more elegant way to perform the validation against a null date?

    TIA

  •  05-08-2009, 10:41 AM Post no. 20824 in reply to 20740

    Re: WinDatePicker's NullDateString

    There is no setting that affect the NullDateString.

    The only thing I can think of is that there is an exception, which is swallowed by the grid or the framework which you don't see.  Is your debugger set to break on all exceptions? (Debug Menu -> Exceptions -> Common Language Runtime Exception, then select "Break into the debugger" radio button in VS2003, or select "Thrown" CheckBox in VS2005).

    If you are in VS2005, make sure the "Enable Just My Code" CheckBox is unselected (Tools Menu -> Options -> Debugging -> General).

    For the null data verification, what you are doing is fine.

     


    André
    Software Developer
    Xceed Software Inc.
  •  05-09-2009, 6:11 AM Post no. 20840 in reply to 20824

    Re: WinDatePicker's NullDateString

    Tried your suggestion but still there is no exception being caught. But in my attempt to automate the replacement of all my usercontrols with Xceed.Editors.WinDatePicker I accidentally found a solution which works on my case. Disregarding all the other initializations created by VS when one drops a WinDatePicker into a form, I instead just used the following properties and it worked as I want it to be.

    this.dateL1.Enabled = false;
    this.dateL1.Location = new System.Drawing.Point(186, 285);
    this.dateL1.Name = "dateL1";
    this.dateL1.Size = new System.Drawing.Size(136, 21);
    this.dateL1.TabIndex = 104;
    this.dateL1.ForeColor = System.Drawing.Color.Navy;
    this.dateL1.NullDateString = "";
    this.dateL1.DropDownControl.SelectedDate = new System.DateTime(((long)(0)));

    I really appreciate your responses, thanks a lot.

  •  05-13-2009, 10:15 PM Post no. 20921 in reply to 20840

    Re: WinDatePicker's NullDateString

    Another solution which works is to just inherit the WinDatePicker and modify the behaviour, as such I will not need to change my treament of the Value which is not a nullable DateTime.

    public partial class CustomDateTimePicker : Xceed.Editors.WinDatePicker
    {
      private DateTime? dtNullable;

      public CustomDateTimePicker()
      {
      base.NullDateString = string.Empty;
      base.Value = base.NullDate;
      InitializeComponent();
      }

      public new DateTime? Value
      {
      get
      {
      if (dtNullable.HasValue)
      return base.Value;
      return null;
      }
      set
      {
      if (value == null)
      {
      dtNullable = null;
      base.Value = base.NullDate;
      }
      else
      {
      if (value == base.NullDate)
      {
      dtNullable = null;
      base.Value = base.NullDate;
      }
      else
      {
      dtNullable = value.Value;
      base.Value = value.Value;
      }
      }
      OnValueChanged(EventArgs.Empty);
      }
      }

      protected override void OnValueChanged(EventArgs eventargs)
      {
      if (!this.dtNullable.HasValue)
      base.Value = base.NullDate;

      base.OnValueChanged(eventargs);
      }

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.