Beispiel #1
0
        // use this method when you do not have an actual IField to get the validation info from
        public void AddControlValidationInfo(FieldProxy pField, ref TextBox cntrl, enumTextEntryTypes entryType)
        {
            try
            {
                ControlValidationInfo cvi = new ControlValidationInfo();
                cvi.fieldname = pField.Name;

                cvi.fieldname = pField.Name;
                //cvi.fieldindex = fieldInd;
                cvi.length = pField.Length;
                cvi.allownull = pField.IsNullable;

                if (pField.Type == esriFieldType.esriFieldTypeDouble ||
                    pField.Type == esriFieldType.esriFieldTypeSingle ||
                    pField.Type == esriFieldType.esriFieldTypeSmallInteger ||
                    pField.Type == esriFieldType.esriFieldTypeInteger)
                {
                    cvi.precision = pField.Precision;
                    cvi.scale = pField.Scale;
                }

                cvi.controlname = cntrl.Name;
                cvi.isValid = true;
                cvi.entryType = entryType;

                cntrl.TextChanged += new System.EventHandler(this.Validate);

                cvi.errorprov = new ErrorProvider();
                cvi.errorprov.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
                cvi.errorprov.ContainerControl = m_frm;

                m_controlvalidations.Add(cvi);
            }
            catch(Exception ex)
            {
                util.Logger.Write(" Descrip  : Constructor -- setting up validation for the specified control. " +
                    "\n Message  : " + ex.Message +
                    "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug);

                Debug.WriteLine(ex.Message);
            }
        }
Beispiel #2
0
        // Add a new textbox to validate to this class.
        // overloaded:  Allows user to pass in a delagate to call back to a custom validation function.
        //              This custom function will be used in addition to the basic validation rules.
        public void AddControlValidationInfo(ITable pTable, string fieldName, ref TextBox cntrl, enumTextEntryTypes entryType, CustomTextBoxValidator custValidator)
        {
            try
            {
                ControlValidationInfo cvi = new ControlValidationInfo();
                cvi.fieldname = fieldName;

                int fieldInd = pTable.Fields.FindField(fieldName);
                if (fieldInd == -1)
                {
                    Debug.WriteLine("field " + fieldName + " not found.");
                    return;
                }

                IField pField = pTable.Fields.get_Field(fieldInd);

                cvi.fieldname = pField.Name;
                cvi.fieldindex = fieldInd;
                cvi.length = pField.Length;
                cvi.allownull = pField.IsNullable;

                cvi.controlname = cntrl.Name;
                cvi.isValid = true;
                cvi.entryType = entryType;

                if (pField.Type == esriFieldType.esriFieldTypeDouble ||
                    pField.Type == esriFieldType.esriFieldTypeSingle ||
                    pField.Type == esriFieldType.esriFieldTypeSmallInteger ||
                    pField.Type == esriFieldType.esriFieldTypeInteger)
                {
                    cvi.precision = pField.Precision;
                    cvi.scale = pField.Scale;
                }

                cvi.customValidator = custValidator;

                cntrl.TextChanged += new System.EventHandler(this.Validate);

                cvi.errorprov = new ErrorProvider();
                cvi.errorprov.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
                cvi.errorprov.ContainerControl = m_frm;

                m_controlvalidations.Add(cvi);
            }
            catch(Exception ex)
            {
                util.Logger.Write(" Descrip  : Constructor -- setting up validation for the specified control with a custom validator callback. " +
                    "\n Message  : " + ex.Message +
                    "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug);

                Debug.WriteLine(ex.Message);
            }
        }