private void txtKeyStroke_Validating(object sender, CancelEventArgs e) { string keyStroke = txtKeyStroke.Text; if (txtKeyStroke.Text == "") { e.Cancel = true; errorProvider.SetError(txtKeyStroke, "Key stroke is required."); return; } foreach (ResearcherBehaviorKeyStroke researcherBehaviorKeyStroke in ResearcherBehaviorKeyStroke.AllForListForm()) { if (researcherBehaviorKeyStroke.Behavior.BehavioralTestType == _researcherBehaviorKeyStroke.Behavior.BehavioralTestType && _researcherBehaviorKeyStroke.Behavior != researcherBehaviorKeyStroke.Behavior) { if (keyStroke == researcherBehaviorKeyStroke.KeyStroke) { e.Cancel = true; errorProvider.SetError(txtKeyStroke, "Key stroke is already in use in this behavioral test type. Please press another keystroke"); return; } } } errorProvider.SetError(txtKeyStroke, ""); }
public ResearcherBehaviorKeyStrokeForm(ResearcherBehaviorKeyStroke researcherBehaviorKeyStroke) : this() { if (researcherBehaviorKeyStroke != null) { _researcherBehaviorKeyStroke = researcherBehaviorKeyStroke; } }