K
kenny.deneef
Hey,
I'm searching for a methode to get the the reference to an object I
added into a listview.
I got this class Address
class Address
{
private string street;
private string numb;
private string city;
private string country;
private string phone;
private string gsm;
private string email;
private string fax;
// and so on.....
// all got a property to acces
public Address(string street, string numb, string city, string
country, string phone, string gsm, string email, string fax)
{
this.street = street;
this.numb = numb;
this.city = city;
this.country = country;
this.phone = phone;
this.gsm = gsm;
this.email = email;
this.fax = fax;
}
public ArrayList ToItemList()
{
return new ListViewItem(new string[] { this.Naam, this.Voornaam,
this.Email }, -1);
}
}
In my mainform i got a listview where the street, numb and city are
ArrayList addressList = new ArrayList();
addressList.Add(new Address("street0", "numb0", "city0", "country0",
"phone0", "gsm0", "email0", "fax0"));
addressList.Add(new Address("street1", "numb1", "city1", "country1",
"phone1", "gsm1", "email1", "fax1"));
addressList.Add(new Address("street2", "numb2", "city2", "country2",
"phone2", "gsm2", "email2", "fax2"));
addressList.Add(new Address("street3", "numb3", "city3", "country3",
"phone3", "gsm3", "email3", "fax3"));
listView.Items.Clear();
foreach (Address address in addressList)
{
listView.Items.Add(address.ToItemList());
}
In the listview is now shown
street0 numb0 city0
street1 numb1 city1
street2 numb2 city2
street3 numb3 city3
The problem is now i can't get the other datamebers of a selected
item.
When an items is selected some textfields should get the value of
street, numb, city, country, phone, gsm, email and fax.
Thanks in advanced
I'm searching for a methode to get the the reference to an object I
added into a listview.
I got this class Address
class Address
{
private string street;
private string numb;
private string city;
private string country;
private string phone;
private string gsm;
private string email;
private string fax;
// and so on.....
// all got a property to acces
public Address(string street, string numb, string city, string
country, string phone, string gsm, string email, string fax)
{
this.street = street;
this.numb = numb;
this.city = city;
this.country = country;
this.phone = phone;
this.gsm = gsm;
this.email = email;
this.fax = fax;
}
public ArrayList ToItemList()
{
return new ListViewItem(new string[] { this.Naam, this.Voornaam,
this.Email }, -1);
}
}
In my mainform i got a listview where the street, numb and city are
ArrayList addressList = new ArrayList();
addressList.Add(new Address("street0", "numb0", "city0", "country0",
"phone0", "gsm0", "email0", "fax0"));
addressList.Add(new Address("street1", "numb1", "city1", "country1",
"phone1", "gsm1", "email1", "fax1"));
addressList.Add(new Address("street2", "numb2", "city2", "country2",
"phone2", "gsm2", "email2", "fax2"));
addressList.Add(new Address("street3", "numb3", "city3", "country3",
"phone3", "gsm3", "email3", "fax3"));
listView.Items.Clear();
foreach (Address address in addressList)
{
listView.Items.Add(address.ToItemList());
}
In the listview is now shown
street0 numb0 city0
street1 numb1 city1
street2 numb2 city2
street3 numb3 city3
The problem is now i can't get the other datamebers of a selected
item.
When an items is selected some textfields should get the value of
street, numb, city, country, phone, gsm, email and fax.
Thanks in advanced