当前位置: 首页>>代码示例>>C#>>正文


C# ErrorProvider.GetError方法代码示例

本文整理汇总了C#中System.Windows.Forms.ErrorProvider.GetError方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorProvider.GetError方法的具体用法?C# ErrorProvider.GetError怎么用?C# ErrorProvider.GetError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.ErrorProvider的用法示例。


在下文中一共展示了ErrorProvider.GetError方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetErrorMessages

 public static void GetErrorMessages(Control parentControl, ICollection<string> errorList, ErrorProvider errorProvider )
 {
     string error = errorProvider.GetError(parentControl);
     if (!string.IsNullOrWhiteSpace(error) && !errorList.Contains(error))
         errorList.Add(error);
     foreach (Control control in parentControl.Controls)
         GetErrorMessages(control, errorList, errorProvider);
 }
开发者ID:UtrsSoftware,项目名称:ATMLWorkBench,代码行数:8,代码来源:ErrorManager.cs

示例2: GetandSetErrorTest

		public void GetandSetErrorTest ()
		{
			Form myForm = new Form ();
			myForm.ShowInTaskbar = false;
			Label label1 = new Label ();
			Label label2 = new Label ();
			ErrorProvider myErrorProvider = new ErrorProvider ();
			Assert.AreEqual (string.Empty, myErrorProvider.GetError (label1), "#1");
			myErrorProvider.SetError (label1, "ErrorMsg1");
			Assert.AreEqual ("ErrorMsg1", myErrorProvider.GetError (label1), "#2");
			Assert.AreEqual (string.Empty, myErrorProvider.GetError (label2), "#3");
			myErrorProvider.SetError (label2, "ErrorMsg2");
			Assert.AreEqual ("ErrorMsg2", myErrorProvider.GetError (label2), "#4");
			myErrorProvider.SetError (label2, null);
			Assert.AreEqual ("ErrorMsg1", myErrorProvider.GetError (label1), "#5");
			Assert.AreEqual (string.Empty, myErrorProvider.GetError (label2), "#6");
			myForm.Dispose ();
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:18,代码来源:ErrorProviderTest.cs

示例3: TryFocusInvalidInput

 public static bool TryFocusInvalidInput(ErrorProvider errorProvider, Control control)
 {
     if (!string.IsNullOrEmpty(errorProvider.GetError(control)))
     {
         control.Focus();
         return true;
     }
     return false;
 }
开发者ID:imrekoszo,项目名称:munkanaplo,代码行数:9,代码来源:FormHelpers.cs

示例4: SetError

        public void SetError(ErrorProvider provider , Control control, string message)
        {
            if (!string.IsNullOrEmpty(message))
            {
                if (provider.GetError(control) != "")
                {
                    provider.Clear();
                    Counter--;

                }
                else
                {
                    provider.SetError(control,message);
                    Counter ++;
                }
            }
        }
开发者ID:fadeI,项目名称:GmailReader,代码行数:17,代码来源:ErrorProviderWithCount.cs

示例5: ValidationIsClearedForControlWhenControlPropertyIsSetAndErrorIsCleared

        public void ValidationIsClearedForControlWhenControlPropertyIsSetAndErrorIsCleared()
        {
            ValidationProvider validationProvider = new ValidationProvider();
            validationProvider.SourceTypeName = typeof(ValidationProviderFixtureTestClass).AssemblyQualifiedName;
            MockControl control1 = new MockControl();
            validationProvider.SetSourcePropertyName(control1, "StringProperty");
            ValidatedControlItem controlItem1 = validationProvider.GetExistingValidatedControlItem(control1);
            MockControl control2 = new MockControl();
            validationProvider.SetSourcePropertyName(control2, "StringProperty");
            ValidatedControlItem controlItem2 = validationProvider.GetExistingValidatedControlItem(control2);
            ErrorProvider errorProvider = new ErrorProvider();
            validationProvider.ErrorProvider = errorProvider;

            control1.Text = "000000000001";
            control2.Text = "000000000001";

            validationProvider.PerformValidation(control1);
            validationProvider.PerformValidation(control2);

            Assert.IsFalse(validationProvider.IsValid);
            Assert.IsFalse(controlItem1.IsValid);
            Assert.IsFalse(controlItem2.IsValid);
            Assert.AreEqual("string property", errorProvider.GetError(control1));
            Assert.AreEqual("string property", errorProvider.GetError(control2));

            validationProvider.ValidationPerformed += OnValidationPerformed;
            validationProvider.SetSourcePropertyName(control2, "IntProperty");

            Assert.IsFalse(validationProvider.IsValid);
            Assert.IsFalse(controlItem1.IsValid);
            Assert.IsTrue(controlItem2.IsValid);
            Assert.AreEqual("string property", errorProvider.GetError(control1));
            Assert.AreEqual(string.Empty, errorProvider.GetError(control2));
            Assert.IsNull(validationPerformedEventArgs);

            validationProvider.PerformValidation(control2);

            Assert.IsFalse(validationProvider.IsValid);
            Assert.IsFalse(controlItem1.IsValid);
            Assert.IsFalse(controlItem2.IsValid);
            Assert.AreEqual("string property", errorProvider.GetError(control1));
            Assert.AreEqual("int property", errorProvider.GetError(control2));
            Assert.IsNotNull(validationPerformedEventArgs);
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:44,代码来源:ValidationProviderFixture.cs

示例6: ValueConvertingCallbackSettingConversionErrorMessageWillUseMessageOnErrorProviderIfExists

        public void ValueConvertingCallbackSettingConversionErrorMessageWillUseMessageOnErrorProviderIfExists()
        {
            ValidationProvider validationProvider = new ValidationProvider();
            validationProvider.SourceTypeName = typeof(ValidationProviderFixtureTestClass).AssemblyQualifiedName;
            validationProvider.ValueConvert += OnValueConvertFailing;
            MockControl control1 = new MockControl();
            validationProvider.SetSourcePropertyName(control1, "IntProperty");
            ErrorProvider errorProvider = new ErrorProvider();
            validationProvider.ErrorProvider = errorProvider;

            control1.Text = "5";

            validationProvider.PerformValidation(control1);

            Assert.IsNotNull(valueConvertEventArgs); // callback was called
            Assert.AreEqual(0,
                            MockValidator<object>.CreatedValidators[0].ValidatedTargets.Count); // nothing got validated
            Assert.IsFalse(validationProvider.IsValid); // but the provider is invalid
            Assert.AreEqual("failed conversion", errorProvider.GetError(control1)); // and the error was set on the error provider
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:20,代码来源:ValidationProviderFixture.cs

示例7: ValidationProvider

        public void ExistingValidationErrorsAreClearedWhenDisablingValidationProviderButNotSetAgainWhenEnablingTheValidationProvider()
        {
            ValidationProvider validationProvider = new ValidationProvider();
            validationProvider.SourceTypeName = typeof(ValidationProviderFixtureTestClass).AssemblyQualifiedName;
            validationProvider.RulesetName = "validation";
            MockControl control1 = new MockControl();
            validationProvider.SetSourcePropertyName(control1, "StringProperty");
            ErrorProvider errorProvider = new ErrorProvider();
            validationProvider.ErrorProvider = errorProvider;

            control1.Text = "too long";

            validationProvider.PerformValidation(control1);

            Assert.AreEqual("validation", errorProvider.GetError(control1));

            validationProvider.Enabled = false; // set validation provider to disabled

            Assert.AreEqual("", errorProvider.GetError(control1));

            validationProvider.Enabled = true; // set validation provider to enabled

            Assert.AreEqual("", errorProvider.GetError(control1));
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:24,代码来源:ValidationProviderFixture.cs

示例8: ErrorsInErrorProviderForValidatedControlsAreClearedByValidatorProviderDispose

        public void ErrorsInErrorProviderForValidatedControlsAreClearedByValidatorProviderDispose()
        {
            ValidationProvider validationProvider = new ValidationProvider();
            validationProvider.SourceTypeName = typeof(ValidationProviderFixtureTestClass).AssemblyQualifiedName;
            validationProvider.RulesetName = "validation";
            ErrorProvider errorProvider = new ErrorProvider();
            validationProvider.ErrorProvider = errorProvider;

            MockControl controlWithoutError = new MockControl();
            controlWithoutError.Text = "short";
            validationProvider.SetSourcePropertyName(controlWithoutError, "StringProperty");
            MockControl controlWithError = new MockControl();
            controlWithError.Text = "too long";
            validationProvider.SetSourcePropertyName(controlWithError, "StringProperty");
            MockControl controlWithoutValidation = new MockControl();
            controlWithoutValidation.Text = "too long";

            validationProvider.PerformValidation(controlWithoutError);
            validationProvider.PerformValidation(controlWithError);
            errorProvider.SetError(controlWithoutValidation, "an unmanaged error");

            Assert.AreEqual(string.Empty, errorProvider.GetError(controlWithoutError));
            Assert.AreEqual("validation", errorProvider.GetError(controlWithError));
            Assert.AreEqual("an unmanaged error", errorProvider.GetError(controlWithoutValidation));

            validationProvider.Dispose();

            Assert.AreEqual(string.Empty, errorProvider.GetError(controlWithoutError));
            Assert.AreEqual(string.Empty, errorProvider.GetError(controlWithError));
            Assert.AreEqual("an unmanaged error", errorProvider.GetError(controlWithoutValidation));
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:31,代码来源:ValidationProviderFixture.cs

示例9: ErrorProviderErrorForControlIsClearedAfterPerformingSuccessfulValidation

        public void ErrorProviderErrorForControlIsClearedAfterPerformingSuccessfulValidation()
        {
            ErrorProvider errorProvider = new ErrorProvider();
            ValidationProvider validationProvider = new ValidationProvider();
            validationProvider.SourceTypeName = typeof(ValidationProviderFixtureTestClass).AssemblyQualifiedName;
            validationProvider.RulesetName = "validation";
            validationProvider.ErrorProvider = errorProvider;
            MockControl control = new MockControl();
            ValidatedControlItem validatedControlItem
                = new ValidatedControlItem(validationProvider, control);
            validatedControlItem.SourcePropertyName = "StringProperty";

            control.Text = "too long";
            validationProvider.PerformValidation(validatedControlItem);

            Assert.AreNotEqual(string.Empty, errorProvider.GetError(control));
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:17,代码来源:ValidationProviderFixture.cs

示例10: ValidateForm

        /// <summary>
        /// Validate controls in form using supplied error provider.
        /// </summary>
        /// <param name="erPr"></param>
        /// <param name="ctrl"></param>
        /// <returns></returns>
        public static bool ValidateForm(ErrorProvider erPr, Control ctrl)
        {
            bool isValid = true;

            foreach (Control control in ctrl.Controls)
            {
                control.Focus();
                ctrl.Focus();

                string msg = erPr.GetError(control);

                if (msg != "")
                    isValid = false;
            }

            return isValid;
        }
开发者ID:kanepis,项目名称:ZVIS,代码行数:23,代码来源:TextBoxValidator.cs

示例11: ShowError

		/// <summary>
		/// Shows error message for the given control
		/// </summary>
		/// <param name="control">Control</param>
		/// <param name="errorProvider">Error provider</param>
		/// <param name="error">Error message</param>
		public static void ShowError(Control control, ErrorProvider errorProvider, string error)
		{
			// Current error
			error = (error ?? string.Empty).Trim();
			error = (error.Length == 0) ? null : error;

			// Previous error
			string existingError = errorProvider.GetError(control);
			existingError = (existingError ?? string.Empty).Trim();
			existingError = (existingError.Length == 0) ? null : existingError;

			// Apply
			if (error != null)
			{
				if (existingError == null)
				{
					control.Width -= 32;
				}
				errorProvider.SetError(control, error);
			}
			else
			{
				errorProvider.SetError(control, null);
				if (existingError != null)
				{
					control.Width += 32;
				}
			}
		}
开发者ID:stevebeauge,项目名称:crayon-syntax-snippet-wlw,代码行数:35,代码来源:FormHelper.cs

示例12: txtPageBottom_ValidatedBL

		public void txtPageBottom_ValidatedBL(object sender, EventArgs e)
		{
			try
			{
				bool result = Common.AssignValuePageUnit(cTool.TxtPageBottom, null);
				_errProvider = Common._errProvider;
				if (_errProvider.GetError(cTool.TxtPageBottom) != "")
				{
					_errProvider.SetError(cTool.TxtPageBottom, _errProvider.GetError(cTool.TxtPageBottom));
				}
				else
				{
					ValidatePageHeightMargins(sender, e);
				}
			}
			catch { }
		}
开发者ID:neilmayhew,项目名称:pathway,代码行数:17,代码来源:ConfigurationToolBL.cs


注:本文中的System.Windows.Forms.ErrorProvider.GetError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。