URGENT: dateTimePicker does not reflect "current" value

Posts   
 
    
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 12-Sep-2006 14:40:59   

version 1.0.2005.1 final (self-servicing) VS2005 (pro) winforms


Hiya,

I have a winform that contains a datePicker, "dTimePickerDelivery". This datePicker displays a deliveryDate for a given delivery. This is done via predicates..So far so good.

When I want to create a NEW delivery, I grab the value from dTimePickerDelivery.

However, even AFTER the user has selected a different date , the datePicker still retains the original date.

I have no idea why.Can anyone suggest.I'm in a really big hurry on this one :-(

many thanks,

yogi


tblDeliveryCollection1.Clear(); 
tblDeliveryCollection1.GetMulti(null);

TblDeliveryEntity currDelivery = (TblDeliveryEntity)tblDeliveryCollection1.AddNew();  
                
newProduct.TblDelivery_ = currDelivery ;
currDelivery.ReturnDate = dTimePickerDelivery.Value; //contains the OLD value, even though iI can see on the GUI that the value has changed. 

mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 12-Sep-2006 16:36:49   

Are you sure?

private void button1_Click(object sender, EventArgs e)
{
    MessageBox.Show(dateTimePicker1.Value.ToString());
}

I tested with this code and it works just fine. Are you doing any databinding on the editor?

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 12-Sep-2006 16:56:56   

hiya,

No, I'm not databinding it via the editor.

yes, I am sure that it is grabbing the previous value.

For example, just to test, I grabbed the value when the selectedIndex changes, and it is fine.


private void dTimePickerDelivery_ValueChanged(object sender, EventArgs e)
        {
            // so the value DOES change 
             string currValue = dTimePickerDelivery.Value.ToString();
        }

However, when I add a new item to an entityCollection which is related to the delivery..then it seems that the dTimePickerDelivery databindings seem to be setting it to the previous value

Below is how the datePicker is originally bound:


 dTimePickerDelivery.DataBindings.Clear();
 dTimePickerDelivery.DataBindings.Add(new Binding("Value", this.parentBindingSource, dalStock.TblDeliveryFieldIndex.DeliveryDate.ToString(), true));

Does this make it any clearer?What can I do to toubleshoot this?

Many thanks,

yogi

MarcoP avatar
MarcoP
User
Posts: 270
Joined: 29-Sep-2004
# Posted on: 12-Sep-2006 20:58:00   

Try focing an end edit:

this.parentBindingSource.EndEdit();