private void btnScan_Click(object sender, EventArgs e) { using (var scanForIp = new ScanForIp(_machine)) { // passing this in ShowDialog will set the .Owner // property of the child form scanForIp.ShowDialog(this); txtIPAddress.Text = scanForIp.FoundAddress; } }