Current filter:
          You should refresh the page.
          Not Logged In

          testing the validity of a proposed value with a TextEdit's Mask property

          0
            • How can I check if a value that I want to assign to the TextEdit.Text property satisfies the TextEdit.Mask property? I need a solution that does not assume that the TextEdit control has focus. Is there a way to get a TextEdit control to validate its value when it doesn't have focus?

          0

          Hi Michael,

          You can create a default MaskManager that provides mask functionality according to the current mask type and verify whether the assigned value is valid (see the code below):

          private void simpleButton1_Click(object sender, System.EventArgs e) {
              string testedText = "sample text";
              MaskManager mm = textEdit1.Properties.Mask.CreateDefaultMaskManager();
              mm.SetInitialEditText(testedText);
              if(testedText != mm.GetCurrentEditText() || !mm.IsMatch) {
                  // Do some stuff.
                  MessageBox.Show("Invalid value", "Error");
              }
              else {
                  textEdit1.Text = testedText;
              }
          }

          You must  log in  or  register  to leave an answer