G
Guest
Hi
I have defined my business object OrderItem as shown in the sample code fragment below
public class OrderItem
public event EventHandler UnitPriceChanged
private decimal m_unitPrice = 0.0m
..
public decimal UnitPrice
get { return m_unitPrice;
set
m_unitPrice = value
if (UnitPriceChanged != null) UnitPriceChanged(this, new EventArgs())
I use data binding to bind a TextBox's Text property to the OrderItem's UnitPrice property as follows in my OrderForm
txtUnitPrice.DataBindings.Add("Text", m_orderItem, "UnitPrice")
In some circumstances, when I type in a value in the TextBox and press Tab (or click on another control), the focus does not move to another control but retain in the same TextBox, forever. When this happens, I can't move to other controls anymore except closing down the OrderForm using the "X" button
Later, when I open up another model form - OrderItemDetailForm - and passing it the m_orderItem object for editing. The OrderItemDetailForm performs the same binding to UnitPrice property and everything seems like going fine. When the OrderItemDetailForm's closed and returned its parent, and I attempt to edit the Unit Price thru the txtUnitPrice control, the control locks my form again
May I know what is happening here? Or I have done something that does not conform to Windows Forms data binding practices
Thanks
-Y
I have defined my business object OrderItem as shown in the sample code fragment below
public class OrderItem
public event EventHandler UnitPriceChanged
private decimal m_unitPrice = 0.0m
..
public decimal UnitPrice
get { return m_unitPrice;
set
m_unitPrice = value
if (UnitPriceChanged != null) UnitPriceChanged(this, new EventArgs())
I use data binding to bind a TextBox's Text property to the OrderItem's UnitPrice property as follows in my OrderForm
txtUnitPrice.DataBindings.Add("Text", m_orderItem, "UnitPrice")
In some circumstances, when I type in a value in the TextBox and press Tab (or click on another control), the focus does not move to another control but retain in the same TextBox, forever. When this happens, I can't move to other controls anymore except closing down the OrderForm using the "X" button
Later, when I open up another model form - OrderItemDetailForm - and passing it the m_orderItem object for editing. The OrderItemDetailForm performs the same binding to UnitPrice property and everything seems like going fine. When the OrderItemDetailForm's closed and returned its parent, and I attempt to edit the Unit Price thru the txtUnitPrice control, the control locks my form again
May I know what is happening here? Or I have done something that does not conform to Windows Forms data binding practices
Thanks
-Y