private void Validate_EditSection(object sender, InputBoxValidatingArgs e) { string text = e.Text; if (text.Length == 0) { e.Cancel = true; e.Message = "Section name is required"; return; } byte[] bName = Encoding.Unicode.GetBytes(text); foreach (Section section in xsd[0].sectionCollection.Sections) { if (section.NameEqualsTo(bName)) { MessageBox.Show("Duplicate section name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (null != lstSection.SelectedItem) { Section section = (Section)lstSection.SelectedItem; section.Name = bName; } updateStatus(); }
private void inputBox_Validating(object sender, InputBoxValidatingArgs e) { if (e.Text.Trim().Length == 0 && true) { e.Cancel = true; e.Message = "Required"; } }
private static void inputBox_Validating(object sender, InputBoxValidatingArgs e) { if (e.Text.Trim().Length != 0) { return; } e.Cancel = true; e.Message = "Required"; }
/// <summary> /// Validate the Text using the Validator /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textBoxText_Validating(object sender, System.ComponentModel.CancelEventArgs e) { if (Validator != null) { InputBoxValidatingArgs args = new InputBoxValidatingArgs(); args.Text = textBox.Text; Validator(this, args); if (args.Cancel) { e.Cancel = true; errorProviderText.SetError(textBox, args.Message); } } }
public static void ValidateNameHandler(object sender, InputBoxValidatingArgs e) { if (e.Text.Length == 0) { e.Cancel = true; e.Message = "Name is Required"; } try { new FileInfo(GetPathFromName(e.Text)); } catch (Exception) { e.Cancel = true; e.Message = "Invalid Characters"; } }
private void Validate_AddSection(object sender, InputBoxValidatingArgs e) { string text = e.Text; if (text.Length == 0) { e.Cancel = true; e.Message = "Section name is required"; return; } byte[] bName = Encoding.Unicode.GetBytes(text); if (xsd.Count < 1) { newXsd(); setupGrid(); } foreach (Section section in xsd[0].sectionCollection.Sections) { if (section.NameEqualsTo(bName)) { MessageBox.Show("Duplicate section name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } xsd[0].sectionCollection.Sections.Add(new Section(0, bName)); updateStatus(); lstSection.ClearSelected(); lstSection.SelectedIndex = lstSection.Items.Count - 1; lstSection.Focus(); dataSectionRows.DataSource = ((Section)lstSection.SelectedItem).XStrings.Rows; }
/// <summary> /// This validates the inputbox and checks if we have zero length. /// The inputbox is shown when the user chooses to specify a filename /// rather then randomly renaming it. /// </summary> private void inputBox_Validating(object sender, InputBoxValidatingArgs argE) { if (argE.Text.Trim().Length == 0) { //if the text is not valid, cancel the event. argE.Cancel = true; argE.Message = "Required"; } }