How do I pass "this" from Form1 in the constructor for the class I'm in?
It depends how are you showing your dialog. Here is example solution:
//Main form
public partial class Form1 : Form
{
//...
private void button1_Click(object sender, EventArgs e)
{
using(Dialog dlg = new Dialog(this))
{
dlg.ShowDialog();
}
}
//...
}
//Dialog form
public partial class Dialog : Form
{
private Form1 form;
public Dialog(Form1 form)
{
InitializeComponent();
this.form = form;
}
private void Dialog_FormClosing(object sender, FormClosingEventArgs e)
{
form.Refresh();
}
}
No comments:
Post a Comment