0
は、あなたが私のプログラムを見ることができます上の写真から、
リストビューに表示されます。私が持っている問題は、ボトムの国のための私のコンボボックスが私のリストビューに表示されているということです。私は理由を知らないが、それは国が文字列ではないことと関係があるのだろうか?解決策は何ですか?私はこれと一緒に非常に長い時間をかけています、私はあなたのために助けが必要です。事前のおかげで
フォーム1 =リストビュー
フォーム2 =私の顧客管理(上の写真)ここでダウン
はここにダウンをForm1
内public partial class MainForm : Form
{
CustomerFiles.Contact contact = new CustomerFiles.Contact();
CustomerFiles.Address address = new CustomerFiles.Address();
CustomerFrame customerframe = new CustomerFrame();
private void MainForm_Load(object sender, EventArgs e)
{
if (customerframe.ShowDialog() == DialogResult.OK) //if button OK is clicked then value will be inserted
{
// var item = string.Format("[{0}]",contact.ToString());
listView1.Items.Add(string.Format("[{0}]", customerframe.ToString()));
}
}
で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)
{
// inside contact
contact.FirstName = tbFirstName.Text;
firstName = contact.FirstName;
contact.LastName = tbLastName.Text;
lastName = contact.LastName;
contact.PhoneData = new CustomerFiles.Phone(tbCellPhone.Text);
phone = contact.PhoneData;
contact.PhoneData = new CustomerFiles.Phone(tbHomePhone.Text);
email = contact.EmailData;
//inside address class
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}]", contact.ToString(), address.ToString());
}
ここに私のアドレスの中にあるcフォームからのTextプロパティを追加しているように見えます
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);
}
}