protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (ParentForm != null) { ParentForm.FormClosing += (s, e2) => { if (ParentForm.DialogResult == DialogResult.OK) { var settings = mDatabaseSettingsBindingSource.DataSource as DatabaseSettings; mDatabase.SetKeeAgentSettings(settings); } }; } }