public void RefreshListBox() { listBox1.Items.Clear(); //Read xml add items to listbox MessageBox.Show("Refreshed");
}
private void button1_Click(object sender, EventArgs e) { Form2 frmTarget = new Form2(); frmTarget.Show(this);//<---note the 'this' } } public partial class Form2 : Form { public Form2() { InitializeComponent(); }
{
public Form1()
{
InitializeComponent();
}
public void RefreshListBox()
{
listBox1.Items.Clear();
//Read xml add items to listbox
MessageBox.Show("Refreshed");
}
private void button1_Click(object sender, EventArgs e)
{
Form2 frmTarget = new Form2();
frmTarget.Show(this);//<---note the 'this'
}
} public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
((Form1)this.Owner).RefreshListBox();
}
}