I have entity Aircraft which has entity field VehicleModel.
Aircraft also has a field (created using the designer) VehmodName which is set to be Aircraft.VehicleModel.VehmodName.
In my winforms apps I use the central visual theme of having a devexpress grid at the top of a form and then editors at the bottom half of the form to edit the current record in the grid.
I use fields of entity fields in the grid to provide sorting and filtering capabilities (for example VehmodName).
But then I have a lookupedit in the bottom half of the form to actually set the id using a visually compelling metaphor.
In this case, I have a devexpress lookupedit bound to the current aircraft's VehmodId and its lokup datasource bound to an entitycolelction using the VehicleModel factory.
The problem is that, when I set the VehicleModel using the lookupedit, I'd like to immediately update the VehmodName in the upper grid to reflect the change.
So, the idea is to trap the onvaluechanged event in the lookupedit and set the aircraft.VehicleModel to the VehcileModel corresponding to the currently selected VehicleModel in the lookupedit. This immediately updates the VehmodName in the grid, which is exactly what I want, but when I change the focused field, the VehmodName value dissapears from the grid (becomes blank).
My question is why does this happen? VehmodName is dynamically computed in the AircrafrtEntity through a property getter to be the aircraft.VehicleModel.VehmodName. And when I make the change to the VehicleModel, I see the reflected change immediately, but then it seems the VehicleModel change gets undone when I change focus to another field in the detail editors...
Thanks
private void lookUpEdit1_EditValueChanged(object sender, EventArgs e)
{
(aircraftBindingSource.Current as AircraftEntity).VehicleModel=
lookUpEdit1.Properties.GetDataSourceRowByKeyValue(lookUpEdit1.EditValue) as VehicleModelEntity;
}
public IPrefetchPath2 GetPrefetchPath()
{
PrefetchPath2 pfp = new PrefetchPath2((int)EntityType.AircraftEntity);
pfp.Add(AircraftEntity.PrefetchPathAircraftBase);
pfp.Add(AircraftEntity.PrefetchPathVehiclePicture);
pfp.Add(AircraftEntity.PrefetchPathOperator);
pfp.Add(AircraftEntity.PrefetchPathVehicleModel);
return pfp;
}
The VehicleModelEntity instance that I am trying to set the aircraft.VehicleModel to is coming from a different EntityCollection that populates a lookupedit. Does this matter?
There is no other code being executed in the form that would interfere with this...