J
Jacek Jurkowski
.... bind nullable control property to nullable value?
The simpliest scenario:
public class a
{
Nullable<DateTime> myDate = null;
public Nullable<DateTime> MyDate
{
get{return myDate;}
set{myDate = value;}
}
}
public class MyControl : UserControl
{
Nullable<DateTime> date = null;
public Nullable<DateTime> Date
{
get{return date;}
set{date = value;}
}
}
public class MyForm : Form
{
a class_a = new a();
MyControl my_control = new MyControl();
protected override void OnLoad(EventArgs e)
{
this.Controls.Add(my_control);
// Next line causes the error.
// "Cannot format the value to the desired type".
my_control.DataBindings.Add("Date",class_a,"MyDate");
}
}
What to do to allow such binding in the simpliest way?
The simpliest scenario:
public class a
{
Nullable<DateTime> myDate = null;
public Nullable<DateTime> MyDate
{
get{return myDate;}
set{myDate = value;}
}
}
public class MyControl : UserControl
{
Nullable<DateTime> date = null;
public Nullable<DateTime> Date
{
get{return date;}
set{date = value;}
}
}
public class MyForm : Form
{
a class_a = new a();
MyControl my_control = new MyControl();
protected override void OnLoad(EventArgs e)
{
this.Controls.Add(my_control);
// Next line causes the error.
// "Cannot format the value to the desired type".
my_control.DataBindings.Add("Date",class_a,"MyDate");
}
}
What to do to allow such binding in the simpliest way?