New Posts New Posts RSS Feed: how to make EntityAspect.EntityState become modified?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

how to make EntityAspect.EntityState become modified?

 Post Reply Post Reply
Author
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Topic: how to make EntityAspect.EntityState become modified?
    Posted: 29-Jun-2009 at 1:27pm
Try DataSourceUpdateMode;  here are some words from the IdeaBlade Classic Reference Help:
DataSourceUpdateMode

Before we leave the discussion of the ControlBindingDescriptor’s validation-related behavior, let’s take a look at one more of the ControlBindingDescriptor’s properties: DataSourceUpdateMode, a property inherited from the System.Windows.Forms.Binding class.  By default this is set to DataSourceUpdateMode.OnValidation, meaning that the value of the bound business object property won’t be updated until the Validating event fires for the control.  There are occasions when you might want it to be updated differently.  Another member of the DataSourceUpdateMode enum, OnPropertyChanged, causes the business object property to get updated with each change of the value in the control.  With that setting, the business object will get updated with each new keystroke typed into a TextBox, or with each new item selected as you scroll through the items in a ComboBox.

Here’s one scenario where the latter behavior would be useful:  Suppose your Employee form displays each Employee’s Manager in a ComboBox. But suppose it also displays the Manager’s photo and organizational title in other controls.  Normally, as your end user scrolled through potential Managers in the ComboBox list, the related Photo and Title would remain unchanged.  They would not change until the user actually tabbed or clicked into some control other than the ComboBox, thereby causing the latter’s Validating event to fire.  But you might want your user to see each prospective Manager’s photo and title as she moved through the ComboBox list.  By setting the DataSourceUpdateMode for the ComboBox’s ControlBindingDescriptor to OnPropertyChanged, you would get the desired behavior.

Another scenario using the OnPropertyChanged setting for the DataSourceUpdateMode might be a TextBox where you want to validate the entered value as each keystroke is entered.  If commas had no place in the value, you could stop the user in her tracks as soon as she entered one. For most circumstances this constitutes carrying the principle of immediate feedback maybe a little far, but you may have a use case where it makes sense.

DataSourceUpdateMode has one more setting: Never.  This can be used to turn off data binding temporarily without disturbing the configuration of the bindings.

 
Now, here is some code from an IdeaBlade Classic VB project using DevExpress controls:
 
unitCBM.Descriptors.Get(originCustomerLookUpEdit).DataSourceUpdateMode = _DataSourceUpdateMode.OnPropertyChanged

unitCBM.Descriptors.Get(originAddressLookUpEdit).DataSourceUpdateMode = _DataSourceUpdateMode.OnPropertyChanged

 

Back to Top
monkeyking View Drop Down
Groupie
Groupie
Avatar

Joined: 04-Mar-2009
Location: brisbane
Posts: 68
Post Options Post Options   Quote monkeyking Quote  Post ReplyReply Direct Link To This Post Posted: 25-Jun-2009 at 5:49pm
I'm using a XtraGridView to bind with an datasouce, the problem is, once i change a cell value, the EntityAspect.EntityState can not detect the changes unless I move the focus into other cells. what i want is, once i change the cell value, the EntityAspect.EntityState can be set into modified immediatly without moving focus, so i'm able to save it.

there is a bit problem in the saving feature, once i close the window, i want to save the changes, but because EntityAspect.EntityState doesn't change, so i can't do it. but the thing makes me confuse abt is that it works if I just save it without closing that window and the  EntityAspect.EntityState can be set into modified, but if I save it during closing window, it doesn't work.

Regards
John


Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down