private void btnOK_Click(object sender, EventArgs e) { COMRegistry left = comboBoxLeft.SelectedItem as COMRegistry; COMRegistry right = comboBoxRight.SelectedItem as COMRegistry; if (left == null || right == null) { MessageBox.Show(this, "Please Select Two Registries", "Select Registries", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { try { DiffRegistry = COMUtilities.DiffRegistry(this, left, right, GetDiffMode()); DialogResult = DialogResult.OK; Close(); } catch (OperationCanceledException) { } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }