http://imageshack.us/f/859/skit2.png/
From the picture above you can see that i have inserted values into my
listview. The problem is that the countries which is a combobox does not show
the contries, but instead it shows where the country class exists. I dont know
why, has it to do with that countries is not a string? and whats the solution
Form1 = listview
Form2 = my customer manager
down here is inside Form1: public partial class MainForm :
Form
{
CustomerFiles.
Contact contact =
new CustomerFiles.
Contact();
CustomerFiles.
Address address =
new CustomerFiles.
Address();
CustomerFrame customerframe =
new CustomerFrame();
down here is inside Form2:
public partial class CustomerFrame :
Form
{
CustomerFiles.
Address address =
new CustomerFiles.
Address();
CustomerFiles.
Contact contact =
new CustomerFiles.
Contact();
CustomerFiles.
Countries country =
new CustomerFiles.
Countries();
public string firstName {
get;
set; }
public string lastName {
get;
set; }
internal CustomerFiles.
Phone phone {
get;
set; }
internal CustomerFiles.
Email email {
get;
set; }
internal CustomerFiles.
Address addressinfo {
get;
set; }
public string city {
get;
set; }
internal CustomerFiles.
Countries countryinfo {
get;
set; }
public string street {
get;
set; }
public string zipcode {
get;
set; }
public
CustomerFrame()
{
InitializeComponent();
List<CustomerFiles.
Countries> countries =
new List<CustomerFiles.
Countries> {
new CustomerFiles.
Countries{ CountryId = 1, Name =
"Bulgaria"},
new CustomerFiles.
Countries{ CountryId = 2, Name =
"France"},
new CustomerFiles.
Countries{ CountryId = 3, Name =
"Brazil"},
new CustomerFiles.
Countries{ CountryId = 4, Name =
"Russia"},
new CustomerFiles.
Countries{ CountryId = 5, Name =
"South Africa"},
new CustomerFiles.
Countries{ CountryId = 6, Name =
"Kurdistan"},
new CustomerFiles.
Countries{ CountryId = 7, Name =
"China"},
new CustomerFiles.
Countries{ CountryId = 8, Name =
"Japan"},
new CustomerFiles.
Countries{ CountryId = 9, Name =
"United States of America"},
new CustomerFiles.
Countries{ CountryId = 10, Name =
"UK"},
new CustomerFiles.
Countries{ CountryId = 11, Name =
"Australia"},
new CustomerFiles.
Countries{ CountryId = 12, Name =
"Germany"},
new CustomerFiles.
Countries{ CountryId = 13, Name =
"Sweden"},};
cbCountry.DataSource = countries;
cbCountry.DisplayMember =
"Name";
cbCountry.ValueMember =
"CountryId";
cbCountry.SelectedValue = 1;
btnOk.DialogResult =
DialogResult.OK;
contact.ToString();
address.ToString();
}
private
void btnOk_Click(
object sender,
EventArgs e)
{
firstName = contact.FirstName;
contact.LastName = tbLastName.Text;
lastName = contact.LastName;
contact.PhoneData =
contact.FirstName = tbFirstName.Text;
new CustomerFiles.
Phone(tbCellPhone.Text);
phone = contact.PhoneData;
contact.PhoneData =
new CustomerFiles.
Phone(tbHomePhone.Text);
email = contact.EmailData;
address.City = tbCity.Text;
city = address.City;
address.Country =
new CustomerFiles.
Countries(cbCountry.Text);
countryinfo = address.Country;
address.Street = tbStreet.Text;
street = address.Street;
address.ZipCode = tbZipCode.Text;
zipcode = address.ZipCode;
}
public override string ToString()
{
return string.Format(
"[{0}, {1}, {2}]", contact.ToString(), address.ToString(), country.Name);
}
}
}
And here is inside my address class
class Address
{
private string city;
public Countries country;
private string street;
private string strErrMessage;
private string zipCode;
public Address()
{
string strErrMessage =
string.Empty;
string street =
string.Empty;
string zipCode =
string.Empty;
string city =
string.Empty;
}
public Address(
string street,
string zipCode,
string city)
{
Street = street;
ZipCode = zipCode;
City = city;
}
public Address(
string street,
string zipCode,
string city,
Countries country)
{
Street = street;
ZipCode = zipCode;
City = city;
Country = country;
strErrMessage =
string.Empty;
}
public
Countries Country
{
get
{
return country;
}
set
{
country =
value;
}
}
public override string ToString()
{
return string.Format(
"[{0}, {1}, {2}, {3}]", city, zipCode, street, country);
}
}
}