[DateTimePicker] propriété DataBindings et DateTime
Bonjour,
J'essaie de me servir de la propriété "DataBindings" d'un DateTimePicker. J'ai un DateTime Nullable que j'essaie de rentrer dedans de cette manière:
Code:
this.dtp_heureRDV.DataBindings.Add("Value", this.demandeCourante, "DateHeureRendezVous");
DateHeureRendezVous est donc une propriété, de type Nullable<DateTime>, de l'objet "demandeCourante".
mais cela me soulève l'exception suivante:
Citation:
{"Impossible de mettre en forme la valeur avec le type souhaité."}
StackTrace:
Citation:
à System.Windows.Forms.Binding.FormatObject(Object value)
à System.Windows.Forms.Binding.PushData(Boolean force)
à System.Windows.Forms.Binding.UpdateIsBinding()
à System.Windows.Forms.Binding.CheckBinding()
à System.Windows.Forms.Binding.SetListManager(BindingManagerBase bindingManagerBase)
à System.Windows.Forms.ListManagerBindingsCollection.AddCore(Binding dataBinding)
à System.Windows.Forms.BindingsCollection.Add(Binding binding)
à System.Windows.Forms.BindingContext.UpdateBinding(BindingContext newBindingContext, Binding binding)
à System.Windows.Forms.Control.UpdateBindings()
à System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e)
à System.Windows.Forms.Control.OnParentBindingContextChanged(EventArgs e)
à System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e)
J'ai beau chercher sur le net je ne trouve pas de piste pour m'aider...
La MSDN m'indique un exemple, mais je fais pareil:
Citation:
Code:
1 2 3 4 5
| /* Bind the DateTimePicker control by adding a new Binding.
The data member of the DateTimePicker is specified by a
navigation path in the form: TableName.RelationName.ColumnName. */
DateTimePicker1.DataBindings.Add(new
Binding("Value", ds, "customers.CustToOrders.OrderDate")); |
Quelqu'un a-t-il une idée qui pourrait me sortir de ce problème?
Merci!
Rastamath69