I am currently writing a program which needs an edit form. This form is to edit a country in the datagridview which I have. I am however confused about how to pass the data from the data gridview in the main form to the relative places on the edit form. I have done most of the coding as shown below. I know I need a method in my AVL class to return all the information of the selected country back to the main form method which then passes it back to the edit form and displays it. If anyone can help me to complete this method I would be grateful, I am unsure what to pass and what to write in this method.
Main form method
public void button2_Click(object sender, EventArgs e)
{
EditCountryForm editform = new EditCountryForm(ref this.countryTree, dataGridView1);
string CountryName = "";
foreach (DataGridViewRow item in this.dataGridView1.SelectedRows)
{
CountryName = item.Cells[0].Value.ToString();
}
Country FindRow = new Country(CountryName, 0, 0, 0, 0,null);
Country EditCountry = countryTree.ReturnCountryInfo(FindRow);
editform.passCountry(EditCountry);
editform.Show();
Edit Form Method
public void passCountry(Country SelectedCountry)
{
this.ToEdit = SelectedCountry;
CountryNameText.Text = ToEdit.name;
CountryText.Text = ToEdit.Name;
GDPGrowthText.Text = ToEdit.GdpGrowth.ToString();
InflationText.Text = ToEdit.Inflation.ToString();
HDIRankingText.Text = ToEdit.HdiRankings.ToString();
TradeBalanceText.Text = ToEdit.TradeBalance.ToString();
}
AVL Tree method
public Country ReturnCountryInfo(Country FindRow)
{
Country SelectedCountry = new Country("", 0, 0, 0, 0,null);
return SelectedCountry;
}