Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ErrorProvider extend with HasErrors property #5912

Closed
tugibaev opened this issue Oct 4, 2021 · 7 comments · Fixed by #6234
Closed

ErrorProvider extend with HasErrors property #5912

tugibaev opened this issue Oct 4, 2021 · 7 comments · Fixed by #6234
Assignees
Labels
api-approved (4) API was approved in API review, it can be implemented api-suggestion (1) Early API idea and discussion, it is NOT ready for implementation area-ErrorProvider Issues relating to ErrorProvider help wanted Good issue for external contributors

Comments

@tugibaev
Copy link

tugibaev commented Oct 4, 2021

Summary

ErrorProvider have a Clear() method which removes all errors on all linked controls. But no any property/method which can show errors are exists.

Rationale and Usage

Current version of ErrorProvider need to create boolean variable and set in on every SetError call to check errors are exists. It makes code less readable.

Proposed API

Add readonly property HasErrors:

namespace System.Windows.Forms {
   public class ErrorProvider {
       public bool HasErrors => this.items.Count > 0;
   }
}

Examples

// err - ErrorProvider placed on form

private bool CheckData(){
	err.Clear(); // Clears old error before new check
	
	if (!File.Exists("C:\\abc.txt"))	
		err.SetError(txtFileName, "File not exists");	
	if (numValue.Value > 100)	
		err.SetError(numValue, "Can't be greater than 100 percent");
		
	// ... other checks here...	
	
	return !err.HasErrors;
}
 

private void Save(){
	// Check values before save
	if (CheckData()){
		//Do save	
	}
}
@tugibaev tugibaev added the api-suggestion (1) Early API idea and discussion, it is NOT ready for implementation label Oct 4, 2021
@RussKie
Copy link
Member

RussKie commented Oct 8, 2021

In general it looks sensible. Please submit a formal API proposal, so we can take to the next level.

@RussKie RussKie added the 📭 waiting-author-feedback The team requires more information from the author label Oct 8, 2021
@RussKie RussKie added this to the Future milestone Oct 8, 2021
@tugibaev
Copy link
Author

Proposal fixed with guide

@ghost ghost removed the 📭 waiting-author-feedback The team requires more information from the author label Oct 28, 2021
@RussKie RussKie added the waiting-on-team This work item needs to be discussed with team or is waiting on team action in order to proceed label Oct 28, 2021
@RussKie RussKie added api-ready-for-review (2) API is ready for formal API review; applied by the issue owner waiting-on-team This work item needs to be discussed with team or is waiting on team action in order to proceed and removed waiting-on-team This work item needs to be discussed with team or is waiting on team action in order to proceed labels Nov 9, 2021
@RussKie RussKie modified the milestones: Future, 7.0 alpha1 Nov 9, 2021
@RussKie
Copy link
Member

RussKie commented Nov 9, 2021

Marking as ready for the API Review Board to consider.

@bartonjs
Copy link
Member

bartonjs commented Nov 16, 2021

Video

Looks good as proposed

namespace System.Windows.Forms {
   public class ErrorProvider {
       public bool HasErrors { get; }
   }
}

@bartonjs bartonjs added api-approved (4) API was approved in API review, it can be implemented and removed api-ready-for-review (2) API is ready for formal API review; applied by the issue owner labels Nov 16, 2021
@RussKie RussKie added help wanted Good issue for external contributors and removed waiting-on-team This work item needs to be discussed with team or is waiting on team action in order to proceed labels Nov 16, 2021
@RussKie
Copy link
Member

RussKie commented Nov 16, 2021

Setting as up for grabs.

@RussKie RussKie modified the milestones: 7.0 alpha1, Future Nov 16, 2021
@eriawan
Copy link
Member

eriawan commented Nov 18, 2021

@RussKie

I think this issue is quite straightforward.
Could I have and work on this issue? Please assign to me, thanks in advance! 🙂

@RussKie
Copy link
Member

RussKie commented Nov 19, 2021

Awesome, all yours @eriawan :)

@ghost ghost added the 🚧 work in progress Work that is current in progress label Nov 26, 2021
@ghost ghost removed this from the Future milestone Dec 15, 2021
@ghost ghost removed the 🚧 work in progress Work that is current in progress label Dec 15, 2021
@dotnet dotnet locked as resolved and limited conversation to collaborators Jan 26, 2022
@elachlan elachlan added the area-ErrorProvider Issues relating to ErrorProvider label Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved (4) API was approved in API review, it can be implemented api-suggestion (1) Early API idea and discussion, it is NOT ready for implementation area-ErrorProvider Issues relating to ErrorProvider help wanted Good issue for external contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants