Esempio n. 1
0
        public static int GetMTBData(MaskedTextBox p_mtb, string p_memo, out double ret_value)
        {
            if (p_mtb.Text.Trim() == ".")
            {
                MessageBox.Show(p_memo + "输入框未填写数据", "漏填数据");
                p_mtb.SelectAll();
                p_mtb.Focus();
                ret_value = 0;
                return(-1);
            }
            double tmp;

            try
            {
                tmp = Convert.ToDouble(p_mtb.Text.Trim());
            }
            catch (Exception)
            {
                MessageBox.Show(p_memo + "输入框填写的数据不正确", "数据不规范");

                p_mtb.Focus();
                p_mtb.SelectAll();
                ret_value = 0;
                return(-1);
            }
            ret_value = tmp;
            return(0);//正确则返回0
        }
Esempio n. 2
0
        void maskedTextBox1_GotFocus(object sender, EventArgs e)
        {
            MaskedTextBox box = (MaskedTextBox)sender;

            box.Tag = true;
            box.SelectAll();
        }
Esempio n. 3
0
        private void txtMEnter(object sender, EventArgs e)
        {
            MaskedTextBox objMtxt = (MaskedTextBox)sender;

            objMtxt.SelectAll();
            objMtxt.BackColor = Color.LightGray;
        }
        /// <summary>
        /// Executes action related to GotFocus event.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">EventArgs.</param>
        private void HandleMaskedTextBoxITEnter(object sender, EventArgs e)
        {
            mMaskedTextBoxIT.SelectAll();

            // Throw got focus event.
            OnGotFocus(new GotFocusEventArgs());
        }
        private void MaskedTextBox_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
        {
            this._originalText = MaskedTextBox.Text;
            IMEChange();
            MaskedTextBox.Background = new SolidColorBrush(System.Windows.Media.Colors.Orange);

            MaskedTextBox.SelectAll();
        }
        /// <summary>
        /// Required to address a flaw in the implementation of the base MaskedTextBox control provided
        /// with the .net framework. Allows automatic selection of text within the control while the
        /// mask is set.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void MaskedDateTextBox_SelectAllOnEnter(object sender, EventArgs e)
        {
            MaskedTextBox m = (MaskedTextBox)sender;

            this.BeginInvoke((MethodInvoker) delegate()
            {
                m.SelectAll();
            });
        }
Esempio n. 7
0
 public void CambiarTxt(ComboBox Actual, MaskedTextBox Nuevo)
 {
     Actual.Enabled   = false;
     Actual.BackColor = System.Drawing.Color.White;
     Nuevo.Enabled    = true;
     Nuevo.BackColor  = System.Drawing.Color.Turquoise;
     Nuevo.Focus();
     Nuevo.SelectAll();
 }
        private void MaskedTextBox_GotFocus(object sender, EventArgs e)
        {
            MaskedTextBox maskedTextBox = sender as MaskedTextBox;

            if (sender == null)
            {
                return;
            }
            maskedTextBox.SelectAll();
        }
Esempio n. 9
0
        public static bool IsPresent(Control control)
        {
            if (control.GetType().ToString() == "MetroFramework.Controls.MetroTextBox")
            {
                var textBox = (MetroTextBox)control;
                if (textBox.Text == "")
                {
                    // MessageBox.Show(textBox.Tag + @" is a required field.", Title);

                    errProvider.SetError(textBox, textBox.Tag + @" is a required field.");
                    textBox.Focus();
                    textBox.SelectAll();
                    return(false);
                }
                else
                {
                    errProvider.SetError(textBox, "");
                    return(true);
                }
            }
            else if (control.GetType().ToString() == "MetroFramework.Controls.MetroComboBox")
            {
                var comboBox = (MetroComboBox)control;
                if (comboBox.Text == "")
                {
                    //MessageBox.Show(comboBox.Tag.ToString() + " is a required field.", Title);
                    errProvider.SetError(comboBox, comboBox.Tag + @" is a required field.");
                    comboBox.Focus();
                    comboBox.SelectAll();
                    return(false);
                }
                else
                {
                    errProvider.SetError(comboBox, "");
                    return(true);
                }
            }
            else if (control.GetType().ToString() == "System.Windows.Forms.MaskedTextBox")
            {
                MaskedTextBox makBox = (MaskedTextBox)control;
                if (makBox.Text == "")
                {
                    errProvider.SetError(makBox, makBox.Tag + @" is a required field ");
                    makBox.Focus();
                    makBox.SelectAll();
                }
                else
                {
                    errProvider.SetError(makBox, "");
                    return(true);
                }
            }
            return(true);
        }
Esempio n. 10
0
        void IpInputControl_GotFocus(object sender, EventArgs e)
        {
            MaskedTextBox Text = ((MaskedTextBox)sender);
            String        temp = Text.Text;

            Text.Text = "";
            Text.AppendText(temp);
            Text.SelectAll();

            _focusedBox = Int32.Parse(Text.Tag.ToString());
        }
Esempio n. 11
0
        public void SelectedTextTest()
        {
            MaskedTextBox mtb;

            mtb = new MaskedTextBox();
            Assert.AreEqual("", mtb.SelectedText, "#S1");
            mtb.Text = "abc";
            Assert.AreEqual("", mtb.SelectedText, "#S2");
            mtb.SelectAll();
            Assert.AreEqual("abc", mtb.SelectedText, "#S3");
            mtb.Dispose();
        }
Esempio n. 12
0
        void maskedTextBox1_MouseUp(object sender, MouseEventArgs e)
        {
            MaskedTextBox box = (MaskedTextBox)sender;

            //如果鼠标左键操作并且标记存在,则执行全选
            if (e.Button == MouseButtons.Left && (bool)box.Tag == true)
            {
                box.SelectAll();
            }

            //取消全选标记
            box.Tag = false;
        }
 //  internal methods
 // 输入焦点应当从当前的列表项转移到前一个列表项
 private void textTitle_PreviousControl(object sender, TabbedControlNavigateEventArgs e)
 {
     e.Processed = false;
     if (((this.SelectedIndex != -1) &&
          (this.SelectedIndex > 0)))
     {
         this.SelectedIndex--;
         //  set focus to date field since moving 'back'
         _textDate.Focus();
         _textDate.SelectAll();
         e.Processed = true;
     }
 }
 public static bool ControlValidate(MaskedTextBox txtBox, string message, ErrorProvider ep)
 {
     if (Convert.ToString(txtBox.Text).Contains("_"))
     {
         ep.SetError(txtBox, $"{message}");
         txtBox.Focus();
         txtBox.SelectAll();
         return(false);
     }
     else
     {
         return(true);
     }
 }
Esempio n. 15
0
        public void _enterPropriedade(MaskedTextBox mskCampo)
        {
            String x = "";

            for (int i = 0; i <= mskCampo.Text.Length - 1; i++)
            {
                if ((mskCampo.Text[i] >= '0' &&
                     mskCampo.Text[i] <= '9') ||
                    mskCampo.Text[i] == ',')
                {
                    x += mskCampo.Text[i];
                }
            }
            mskCampo.Text = x;
            mskCampo.SelectAll();
        }
Esempio n. 16
0
 /// <summary>
 /// Handles the <see cref="E:KeyDown" /> event.
 /// </summary>
 /// <param name="Obj">The object.</param>
 /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
 protected void OnKeyDown(object Obj, KeyEventArgs e)
 {
     if (e.Control && e.KeyCode == Keys.A)
     {
         LollipopTB.SelectAll();
         e.SuppressKeyPress = true;
     }
     if (e.Control && e.KeyCode == Keys.C)
     {
         LollipopTB.Copy();
         e.SuppressKeyPress = true;
     }
     if (e.Control && e.KeyCode == Keys.X)
     {
         LollipopTB.Cut();
         e.SuppressKeyPress = true;
     }
 }
Esempio n. 17
0
 private void SetMaskedTextBoxSelectAll(MaskedTextBox txtbox)
 {
     txtbox.SelectAll();
 }
Esempio n. 18
0
        //Validation des zones
        public static void ValidationZone(MaskedTextBox DateDebut, MaskedTextBox DateFin, TextBox Commentaire, CheckBox Confirmation, out bool etat)
        {
            etat = false;

            if (!DateDebut.MaskCompleted)
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer la date de debut de congé.");
                message.ShowDialog();
                DateDebut.Focus();
                DateDebut.SelectAll();
                return;
            }

            if (!DateFin.MaskCompleted)
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer la date de fin de congé.");
                message.ShowDialog();
                DateFin.Focus();
                DateFin.SelectAll();
                return;
            }

            if (DateDebut.MaskCompleted && DateFin.MaskCompleted)
            {
                DateTime Debut, Fin;

                if (!DateTime.TryParse(DateDebut.Text, out Debut))
                {
                    MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer une date valide.");
                    message.ShowDialog();
                    DateDebut.Focus();
                    DateDebut.SelectAll();
                    return;
                }

                if (!DateTime.TryParse(DateFin.Text, out Fin))
                {
                    MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer une date valide.");
                    message.ShowDialog();
                    DateFin.Focus();
                    DateFin.SelectAll();
                    return;
                }

                Debut = DateTime.Parse(DateDebut.Text);
                Fin   = DateTime.Parse(DateFin.Text);

                if (DateTime.Now.Date > Debut.Date)
                {
                    MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer une date valide.");
                    message.ShowDialog();
                    DateDebut.Focus();
                    DateDebut.SelectAll();
                    return;
                }

                if (Debut.Date > Fin.Date)
                {
                    MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "La date de debut est inférieur que la date de fin.");
                    message.ShowDialog();
                    DateFin.Focus();
                    DateFin.SelectAll();
                    return;
                }
            }

            if (Commentaire.Text == "")
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer la raison de congé.");
                message.ShowDialog();
                Commentaire.Focus();
                Commentaire.SelectAll();
                return;
            }

            if (!Confirmation.Checked)
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez confirmer la demande.");
                message.ShowDialog();
                return;
            }

            etat = true;
        }
Esempio n. 19
0
        private void txtEnter(object sender, EventArgs e)
        {
            TextBox       objtxt  = new TextBox();
            MaskedTextBox objMtxt = new MaskedTextBox();

            //if (sender == txtCode)
            //{
            //    objtxt = txtCode;
            //}

            if (sender == txtName1)
            {
                objtxt = txtName1;

                // 2019/03/16
                MyTextKana.TextKana.textEnter(txtName1);
            }

            if (sender == txtFuri)
            {
                objtxt = txtFuri;
            }

            if (sender == txtName2)
            {
                objtxt = txtName2;
            }

            if (sender == txtTantou)
            {
                objtxt = txtTantou;
            }

            if (sender == txtBusho)
            {
                objtxt = txtBusho;
            }

            if (sender == mtxtZipCode)
            {
                objMtxt = mtxtZipCode;
            }

            if (sender == txtAddress1)
            {
                objtxt = txtAddress1;
            }

            if (sender == txtAddress2)
            {
                objtxt = txtAddress2;
            }

            if (sender == txtTel)
            {
                objtxt = txtTel;
            }

            if (sender == txtFax)
            {
                objtxt = txtFax;
            }

            if (sender == txtEmail)
            {
                objtxt = txtEmail;
            }

            if (sender == txtShimebi)
            {
                objtxt = txtShimebi;
            }

            if (sender == mtxtZipCodeS)
            {
                objMtxt = mtxtZipCodeS;
            }

            if (sender == txtAddress1S)
            {
                objtxt = txtAddress1S;
            }

            if (sender == txtAddress2S)
            {
                objtxt = txtAddress2S;
            }

            if (sender == txtMemo)
            {
                objtxt = txtMemo;
            }

            if (sender == textBox1)
            {
                objtxt = textBox1;
            }

            // 請求先担当者名 2015/11/20
            if (sender == txtTantouS)
            {
                objtxt = txtTantouS;
            }

            // 請求先名称 2015/07/05
            if (sender == txtNameSeikyu)
            {
                objtxt = txtNameSeikyu;
            }

            // 検索電話番号 2015/07/05
            if (sender == txtsTel)
            {
                objtxt = txtsTel;
            }

            // 検索〒番号 2015/07/05
            if (sender == txtsZip)
            {
                objtxt = txtsZip;
            }

            // 検索請求先名称 2015/07/05
            if (sender == textBox2)
            {
                objtxt = textBox2;
            }

            // 検索請求先部署名 2019/02/20
            if (sender == txtBushoS)
            {
                objtxt = txtBushoS;
            }

            objtxt.SelectAll();
            objtxt.BackColor = Color.LightGray;

            objMtxt.SelectAll();
            objMtxt.BackColor = Color.LightGray;
        }
Esempio n. 20
0
        private void txtEnter(object sender, EventArgs e)
        {
            TextBox       objtxt  = new TextBox();
            MaskedTextBox objMtxt = new MaskedTextBox();

            if (sender == txtName)
            {
                objtxt = txtName;
            }

            if (sender == txtDaihyo)
            {
                objtxt = txtDaihyo;
            }

            if (sender == txtYaku)
            {
                objtxt = txtYaku;
            }

            if (sender == txtTel)
            {
                objtxt = txtTel;
            }

            if (sender == txtFax)
            {
                objtxt = txtFax;
            }

            if (sender == txtAddress1)
            {
                objtxt = txtAddress1;
            }

            if (sender == txtAddress2)
            {
                objtxt = txtAddress2;
            }

            if (sender == mtxtZipCode)
            {
                objMtxt = mtxtZipCode;
            }

            if (sender == txtEmail)
            {
                objtxt = txtEmail;
            }

            if (sender == txtBusho)
            {
                objtxt = txtBusho;
            }

            if (sender == txtTantou)
            {
                objtxt = txtTantou;
            }

            if (sender == txtMemo1)
            {
                objtxt = txtMemo1;
            }

            if (sender == txtMemo2)
            {
                objtxt = txtMemo2;
            }

            if (sender == txtIraiCode)
            {
                objtxt = txtIraiCode;
            }

            if (sender == txtIraiName)
            {
                objtxt = txtIraiName;
            }

            if (sender == txtBankCode)
            {
                objtxt = txtBankCode;
            }

            if (sender == txtBankName)
            {
                objtxt = txtBankName;
            }

            if (sender == txtShitenName)
            {
                objtxt = txtShitenName;
            }

            if (sender == txtShitenCode)
            {
                objtxt = txtShitenCode;
            }

            if (sender == txtNumber)
            {
                objtxt = txtNumber;
            }

            if (sender == txtFlg)
            {
                objtxt = txtFlg;
            }

            if (sender == txtZipPath)
            {
                objtxt = txtZipPath;
            }

            if (sender == txtSheet)
            {
                objtxt = txtSheet;
            }

            objtxt.SelectAll();
            objtxt.BackColor = Color.LightGray;

            objMtxt.SelectAll();
            objMtxt.BackColor = Color.LightGray;
        }
        //validation des entrés
        public static void ValiderDonner(TextBox txtCIN, TextBox txtNom, TextBox txtPrenom, MaskedTextBox txtDN, ComboBox comboSexe, TextBox txtTél, TextBox txtAdresse, ComboBox comboFonction, TextBox txtEmail, TextBox txtLogin,
                                         TextBox txtMDP, TextBox txtMDPC, out bool etat)
        {
            //variable locale
            DateTime date;
            Regex    emailRegex = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"); //regex pour valider le format d'email

            etat = false;

            if (txtCIN.Text.Trim() == "")
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer le CIN.");
                message.ShowDialog();
                txtCIN.Focus();
                txtCIN.SelectAll();
                return;
            }

            if (txtNom.Text.Trim() == "")
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer le Nom.");
                message.ShowDialog();
                txtNom.Focus();
                txtNom.SelectAll();
                return;
            }

            if (txtPrenom.Text.Trim() == "")
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer le Prénom.");
                message.ShowDialog();
                txtPrenom.Focus();
                txtPrenom.SelectAll();
                return;
            }

            if (!DateTime.TryParse(txtDN.Text, out date) || Convert.ToDateTime(txtDN.Text) >= DateTime.Now)
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer une date valide.");
                message.ShowDialog();
                txtDN.Focus();
                txtDN.SelectAll();
                return;
            }

            if (comboSexe.SelectedIndex < 0)
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez selectionner le sexe.");
                message.ShowDialog();
                comboSexe.Focus();
                return;
            }

            if (txtTél.Text.Trim() == "")
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer le Téléphone.");
                message.ShowDialog();
                txtTél.Focus();
                txtTél.SelectAll();
                return;
            }

            if (txtAdresse.Text.Trim() == "")
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer l'Adresse.");
                message.ShowDialog();
                txtAdresse.Focus();
                txtAdresse.SelectAll();
                return;
            }

            if (comboFonction.SelectedIndex < 0)
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez selectionner la fonction.");
                message.ShowDialog();
                comboFonction.Focus();
                return;
            }

            if (txtEmail.Text.Trim() == "")
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer l'Adresse email.");
                message.ShowDialog();
                txtEmail.Focus();
                txtEmail.SelectAll();
                return;
            }

            if (emailRegex.IsMatch(txtEmail.Text) == false)
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Adresse email invalide.");
                message.ShowDialog();
                txtEmail.Focus();
                txtEmail.SelectAll();
                return;
            }

            if (txtLogin.Text.Trim() == "")
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer le Login.");
                message.ShowDialog();
                txtLogin.Focus();
                txtLogin.SelectAll();
                return;
            }

            if (txtMDP.Text.Trim() == "")
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer le Mot de passe.");
                message.ShowDialog();
                txtMDP.Focus();
                txtMDP.SelectAll();
                return;
            }

            if (txtMDPC.Text != txtMDP.Text)
            {
                MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Veuillez entrer un Mot de passe valide.");
                message.ShowDialog();
                txtMDP.Focus();
                txtMDP.SelectAll();
                txtMDPC.Focus();
                txtMDPC.SelectAll();
                return;
            }

            etat = true;
        }
Esempio n. 22
0
        void IPAddressInputBox_MouseUp(object sender, MouseEventArgs e)
        {
            MaskedTextBox text = (MaskedTextBox)sender;

            text.SelectAll();
        }
Esempio n. 23
0
 public void SelectAll()
 {
     baseTextBox.SelectAll();
 }
Esempio n. 24
0
        private void txtEnter(object sender, EventArgs e)
        {
            TextBox       objtxt  = new TextBox();
            MaskedTextBox objMtxt = new MaskedTextBox();

            //if (sender == txtCode)
            //{
            //    objtxt = txtCode;
            //}

            if (sender == txtFuri)
            {
                objtxt = txtFuri;
            }

            if (sender == txtName2)
            {
                objtxt = txtName2;

                // 2019/03/16
                MyTextKana.TextKana.textEnter(txtName2);
            }

            if (sender == txtTantou)
            {
                objtxt = txtTantou;
            }

            if (sender == txtBusho)
            {
                objtxt = txtBusho;
            }

            if (sender == mtxtZipCode)
            {
                objMtxt = mtxtZipCode;
            }

            if (sender == txtAddress1)
            {
                objtxt = txtAddress1;
            }

            if (sender == txtAddress2)
            {
                objtxt = txtAddress2;
            }

            if (sender == txtTel)
            {
                objtxt = txtTel;
            }

            if (sender == txtFax)
            {
                objtxt = txtFax;
            }

            if (sender == txtEmail)
            {
                objtxt = txtEmail;
            }

            if (sender == txtMemo)
            {
                objtxt = txtMemo;
            }

            if (sender == textBox1)
            {
                objtxt = textBox1;
            }

            if (sender == txtShiharaibi)
            {
                objtxt = txtShiharaibi;
            }

            objtxt.SelectAll();
            objtxt.BackColor = Color.LightGray;

            objMtxt.SelectAll();
            objMtxt.BackColor = Color.LightGray;
        }