C
c_xyTopa
Hi all,
i have 2 Forms - ListView and DetailView.
By clicking any element of the ListView the clicked order-object is passed
to the DetailView, where it can be modified.
If the order is modified and than a "Cancel"-button clicked, you navigate
back to ListView.
As a result you see a modified order, wich was actualy not saved.
To avoid this I create a clone of the selected order and if a
"Cancel"-button is clicked and a clone is not the same as order I assign
clone to the order.
But still in the ListView i get the modified object...
What is the problem?
Thanx
--------------------OrderClass-----------------------------
public class Order : ICloneable
{
public object Clone()
{
Order clone = this.MemberwiseClone() as Order;
return clone;
}
public override bool Equals(object obj)
{ . }
}
--------------------OrderDetails-----------------------------
public partial class OrderDetails : Form
{
private Order _order;
private Order _clone;
public OrderDetails(Order order)
{
_order = order;
_clone = this._order.Clone() as Order;
InitializeComponent();
}
// close-btn
private void menuItem1_Click(object sender, EventArgs e)
{
if (!_order.Equals(_clone))
_order = _clone;
this.Close();
}
}
i have 2 Forms - ListView and DetailView.
By clicking any element of the ListView the clicked order-object is passed
to the DetailView, where it can be modified.
If the order is modified and than a "Cancel"-button clicked, you navigate
back to ListView.
As a result you see a modified order, wich was actualy not saved.
To avoid this I create a clone of the selected order and if a
"Cancel"-button is clicked and a clone is not the same as order I assign
clone to the order.
But still in the ListView i get the modified object...
What is the problem?
Thanx
--------------------OrderClass-----------------------------
public class Order : ICloneable
{
public object Clone()
{
Order clone = this.MemberwiseClone() as Order;
return clone;
}
public override bool Equals(object obj)
{ . }
}
--------------------OrderDetails-----------------------------
public partial class OrderDetails : Form
{
private Order _order;
private Order _clone;
public OrderDetails(Order order)
{
_order = order;
_clone = this._order.Clone() as Order;
InitializeComponent();
}
// close-btn
private void menuItem1_Click(object sender, EventArgs e)
{
if (!_order.Equals(_clone))
_order = _clone;
this.Close();
}
}