private void clearForm() { toolStripStatusLabel1.Text = ""; foreach (Control C in this.Controls) { if (C.GetType() == typeof(TextBox)) { TextBox txt = (TextBox)C; txt.ResetText(); } else if (C.GetType() == typeof(MaskedTextBox)) { MaskedTextBox txt = (MaskedTextBox)C; txt.ResetText(); } } txtCidade.Text = "Volta Redonda"; txtUF.Text = "RJ"; txtCodigo.Enabled = true; txtCodigo.Select(); txtValor_Contrato.Text = "0"; txtValor_Bruto.Text = "0"; btnApagar.Visible = false; }
private void formatoNota(MaskedTextBox msk) { if (msk.Text == "A" || msk.Text == "B" || msk.Text == "C" || msk.Text == "D" || msk.Text == "a" || msk.Text == "b" || msk.Text == "c" || msk.Text == "d") { msk.Text = msk.Text.ToUpper(); } else { msk.ResetText(); } }
public void ClearControl() { foreach (Control c in panel_in.Controls) { ComboBox cbb = c as ComboBox; if (cbb != null) { cbb.SelectedText = ""; cbb.SelectedIndex = -1; cbb.Text = ""; //cbb.SelectedValue = null; } TextBox t = c as TextBox; if (t != null) { t.ResetText(); } MaskedTextBox mt = c as MaskedTextBox; if (mt != null) { mt.ResetText(); } } foreach (Control c in panel_out.Controls) { ComboBox cbb = c as ComboBox; if (cbb != null) { cbb.SelectedText = ""; cbb.SelectedIndex = -1; cbb.Text = ""; //cbb.SelectedValue = null; } TextBox t = c as TextBox; if (t != null) { t.ResetText(); } MaskedTextBox mt = c as MaskedTextBox; if (mt != null) { mt.ResetText(); } } chkout.Checked = false; cardid = string.Empty; navyid = string.Empty; lblyearintext.Text = string.Empty; lblunittext.Text = string.Empty; lbloldyearintext.Text = string.Empty; }
public string Check_Year(string text) { MaskedTextBox test = new MaskedTextBox(); test.Text = text; if (test.MaskFull) { try { DateTime.ParseExact(test.Text, "yyyy", null); text = test.Text; return(text); } catch { return("Năm không hợp lệ"); MessageBox.Show("Năm không hợp lệ"); test.ResetText(); } } return(text); }
public static void limpar(Form form) { foreach (Control controle in form.Controls) { if (controle is TextBox) { TextBox txt = (controle) as TextBox; txt.Clear(); } if (controle is ComboBox) { ComboBox txt = (controle) as ComboBox; txt.SelectedIndex = -1; } if (controle is ListBox) { ListBox txt = (controle) as ListBox; txt.Items.Clear(); } if (controle is NumericUpDown) { NumericUpDown txt = (controle) as NumericUpDown; txt.Value = 0; } if (controle is MaskedTextBox) { MaskedTextBox txt = (controle) as MaskedTextBox; txt.ResetText(); } if (controle is TabControl) { TabControl txt = (controle) as TabControl; for (int x = 0; x < txt.TabPages.Count; x++) { foreach (Control crl in txt.TabPages[x].Controls) { if (crl is TextBox) { TextBox tot = (crl) as TextBox; tot.Clear(); } if (crl is ComboBox) { ComboBox tot = (crl) as ComboBox; tot.SelectedIndex = -1; } if (crl is ListBox) { ListBox tot = (crl) as ListBox; tot.Items.Clear(); } if (crl is NumericUpDown) { NumericUpDown tot = (crl) as NumericUpDown; tot.Value = 0; } if (!(crl is null) && crl is MaskedTextBox) { MaskedTextBox tot = (crl) as MaskedTextBox; tot.ResetText(); } } } } } }