Home Forums WinForms controls Xceed Grid for WinForms DataBinded WinDatePicker and Validating

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #14602 |

    Hi !

    I’m using a WinDatePicker component from XCeed.Editors (v3.0) and i’m having some trouble getting the component validated when using DataBinding.

    Let’s see without databinding :
    I have a class derivated from WinDatePicker in which I override the OnValidating method.
    When using the control in my application, if I select a real date, the component is validated after losing focus.
    If I select the null date, the component is validated after loosing focus and the NullDateString is showed. The Value of my control is the null date (01/01/1970) I wanted.

    But when using databinding, it doesnt work so well…
    I bind my component to an object with a DateTime property using this method :

    public static void DatePickerBinding(DatePicker target, object dataSource, string dataMember) {
    target.DataBindings.Clear();
    System.Windows.Forms.Binding binding = new System.Windows.Forms.Binding(“Value”, dataSource, dataMember);
    binding.Format += new ConvertEventHandler(SourceToDatePicker);
    binding.Parse += new ConvertEventHandler(DatePickerToSource);
    target.DataBindings.Add(binding);
    }

    [Both convert handlers are like empty (used them to try and debug)]
    dataSource is the source object.
    dataMember the member.

    When using the component, if I select a “real” date in the component, the control is validated and binding is done, the object property is set to the selected date.

    But when I select the null date, binding doesnt work. During the OnValidating of the control, we have base.OnValidating(e) which makes validation canceled.

    In base.OnValidating(e), with breakpoints we can see it goes to the DatePickerToSource method with e.Value = 01/01/1970 (my null date), then to SourceToDatePicker [with e.Value = System.DBNull.Value] (why SourceToDatePicker? without changing source). It goes back to OnValidating of my DatePicker class, and e.Cancel turns to true, which cancel validation of the control and also make it ignores the binding.

    The binded property of my binded class is not called with a null date.

    Could you tell me what on the base.OnValidating(e) makes it cancel ? Is it during Binding phase ? I tried to handle the DBNull with setting e.Value to new DateTime(1970, 1, 1) but i got same results…

    Maybe I can try to use the WinDatePicker.ValueChanged event, but why is databinding not working with null value ? Any idea ?

    Thanks

    Imported from legacy forums. Posted by Charles (had 4753 views)

    User (Old forums)
    Member
    Post count: 23064

    Did you ever get an answer to this — it appears that this might be the same (or at least simalar) to the issue I’m having with the WDP control.

    Nathan.

    Imported from legacy forums. Posted by Nathanael (had 312 views)

    User (Old forums)
    Member
    Post count: 23064

    Our developer could not reproduce the problem. Can you send a sample application to <a href=”mailto:support@xceedsoft.com”>support</a> so we can investigate the issue further?

    Imported from legacy forums. Posted by André (had 377 views)

    User (Old forums)
    Member
    Post count: 23064

    This is a bug. The WinDatePicker’s dynamic Bindings always parses to null string when the desired DataType is string.

    The fix for this will be available in our next release, which will be out sometime in September 2006.

    Imported from legacy forums. Posted by André (had 267 views)

    User (Old forums)
    Member
    Post count: 23064

    Any updated time frame?

    Nathan.

    Imported from legacy forums. Posted by Nathanael (had 369 views)

    User (Old forums)
    Member
    Post count: 23064

    It is now available <a href=”http://www.xceedsoft.com/download/updates.aspx”>here</a&gt;.

    Imported from legacy forums. Posted by André (had 204 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks! Well try it out and see if that fixes it for me.

    Nathan.

    Imported from legacy forums. Posted by Nathanael (had 5537 views)

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.