Cor,
Thanks for your time. I am sure the example works.
My code is has 2 tables in a list/detail relationship. If I try and use the
'Value'' binding I get an exception saying that not all variable can be bound.
Another problem I am working on.
I thought I could get a round it using the 'Text'. I'll try debugging on
the dateTimePicker1_ValueChanged an see any difference.
Thanks
"Cor Ligthert" wrote:
> Garry,
>
> I tried it with this piece of code and did not see anything strange.
>
> Maybe you can try it yourself it only needs a new form wiht a datatimepicker
> and a button and paste than this piece of code.
>
> DataTable dt;
> private void Form3_Load(object sender, System.EventArgs e)
> {
> dt = new DataTable();
> dt.Columns.Add("Gary",Type.GetType("System.DateTime"));
> for (int i = 0;i<10;i++)
> {
> dt.Rows.Add(dt.NewRow());
> dt.Rows[i]["Gary"] = DateTime.Now.AddDays(i);
> }
> dateTimePicker1.DataBindings.Add("Value",dt,"Gary");
> dateTimePicker1.Format = DateTimePickerFormat.Custom;
> dateTimePicker1.CustomFormat = "ddd MMMM d h:mm tt";
> }
> private void button1_Click(object sender,
> System.EventArgs e)
> {
> CurrencyManager cm = (CurrencyManager) BindingContext[dt];
> if (cm.Position>8) cm.Position = -1;
> cm.Position++;
> }
> private void dateTimePicker1_ValueChanged
> (object sender, System.EventArgs e)
> {
> BindingContext[dt].EndCurrentEdit();
> }
>
> I hope this helps a little bit?
>
> Cor
>
>
>
|