private void btnAdvanced_Click(object sender, EventArgs e) { if (SelectedDataSource is IDbDriver) { AdvancedReadDialog advReadDialog = new AdvancedReadDialog(this.SelectedDataSource as IDbDriver); advReadDialog.SQLQuery = this.SQLQuery; DialogResult result = advReadDialog.ShowDialog(); if (result == DialogResult.OK) { sqlQuery = advReadDialog.SQLQuery; OnOK(); } else { this.DialogResult = System.Windows.Forms.DialogResult.None; } } }