Thanks for your attention Miha,
Okay i'll try to keep it brief:
Imagine a form with a listview on the left.
In the background of the form there is an objerct called
theCase of custom type Case.
This contains an arraylist of references to all customer
objects.
The list view on the left represent all the customers, if
you click add customer this happens.
private void btnAddApplicant_Click(object sender,
System.EventArgs e)
{
ready = true;
ctr++;
Customer c = new Customer();
c.PersonalDetails.FirstName = "Name";
c.PersonalDetails.SecondName = "Me" + ctr.ToString();
theCase.Customers.Add(c);
ListViewItem lvi = new ListViewIte
(c.PersonalDetails.FirstName + " " +
c.PersonalDetails.SecondName, 0);
lvi.Tag = (object)c;
lvi.Selected = true;
this.lstCustomers.Items.Add(lvi);
}
So I put the reference into theCase as well as the Tag of
the listview.
If the selected index of the listview changes this happens.
if(this.lstCustomers.SelectedItems != null)
{
if(this.lstCustomers.SelectedItems.Count>0)
{
if(ready)
{
this.txtPersonalC1FirstName.Focus();
SaveCustomer();
theCustomer = (Customer) lstCustomers.SelectedItems[0].Tag;
this.PopulateFromCustomer(theCustomer);
foreach(ListViewItem listItems in lstCustomers.Items)
{
listItems.ImageIndex = 0;
}
lstCustomers.SelectedItems[0].ImageIndex = 1;
if(theCase.Customers.Count<2)
{
this.btnCopyAddresses.Visible = false;
this.btnCopyDependants.Visible = false;
}
else
{
this.btnCopyAddresses.Visible = true;
this.btnCopyDependants.Visible = true;
}
CreateSelfCertTable();
RefreshCopyCombos();
}
CreateSelfCertTable();
RefreshCopyCombos();
}
}
}
Save Customer does this.
private void SaveCustomer()
{
foreach(ListViewItem lvi in this.lstCustomers.Items)
{
if(lvi.ImageIndex == 1)
{
theCustomer = this.SaveCustomerFromForm();
lvi.Text = theCustomer.PersonalDetails.FirstName + " " +
theCustomer.PersonalDetails.SecondName;
lvi.Tag = (object)theCustomer;
break;
}
}
}
Do you remember at the top when I created the objects I
put a refrence in theCase custom type of Case.
Thing is is that I pass this object to my copyCommand form
and it has customers with their inital names ("Name Me1")
rather then the names i've put on since then.
With the load and the save method i have twined in with
the selected item changed event I can see that I am making
changes and these are being registered with the Customer
object as they are loading out all the details corrctly.
Any idea why theCase has outofdate references?
If you've got this far I thank you for your patience.

jax
-----Original Message-----
Hi,
Tag is an object reference thus it stores the reference and does more
nothing to it.
What exactly is your problem?
Can you give us an example?
--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
.