how to set datetimepicker with null value if date not selected(c# winforms)

后端 未结 6 1029
夕颜
夕颜 2020-12-14 03:21
Binding b = new Binding( \"Value\", person, \"BdayNullable\", true );
dtBirthdayNullable.DataBindings.Add( b );
b.Format += new ConvertEventHandler( dtBirthdayNullab         


        
6条回答
  •  一个人的身影
    2020-12-14 03:39

    You can check if your binding source delivers a "null date" or a date value that you don't want to display.

    If so, select custom format:

    yourDTP.Format = DateTimePickerFormat.Custom
    yourDTP.CustomFormat = " "
    

    Add a "CloseUp" or "ValueChanged" event handler to reset the format on user action:

    yourDTP.Format = DateTimePickerFormat.Short
    

提交回复
热议问题