Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8316839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:26:56+00:00 2026-06-08T21:26:56+00:00

I am trying to validate User Input in Windows Forms Application (using MVP design

  • 0

I am trying to validate User Input in Windows Forms Application (using MVP design Pattern). Since this is my first project using MVP, I am not very clear where and how to put the user input validation code.
To be specific, I have a Products form which contains two text box controls, Namely ProductName and ProductPrice.

Below is the code for my ProductForm, IProductView and ProductPresenter

IProductView.cs

 public interface IProductView
    {
        string ProductName { get; set; }
        int ProductPrice { get; set; }

        event EventHandler<EventArgs> Save; 
    }

frmProduct.cs

public partial class frmProduct : Form,IProductView
    {
        ProductPresenter pPresenter;

        public frmProduct()
        {
            InitializeComponent();
            pPresenter = new ProductPresenter(this);
        }

        public new string ProductName
        {
            get
            {
                return txtName.Text;
            }
        }

        public int ProductPrice
        {
            get
            {
                return Convert.ToInt32(txtPrice.Text);
            }
        }

        public event EventHandler<EventArgs> Save;
    }

ProductPresenter.cs

public class ProductPresenter
{
    private IProductView pView;

    public ProductPresenter(IProductView View)
    {
        this.pView = View;
        this.Initialize();
    }

    private void Initialize()
    {
        this.pView.Save += new EventHandler<EventArgs>(pView_Save);

    void pView_Save(object sender, EventArgs e)
    {
        throw new NotImplementedException();
    }
}

I do want to use the ErrorProvider(EP) Control + since I would be using EP control on many forms, I would really love if I could reuse most of the code by putting the EP code in some method and passing it the controls and appropriate message. Where should I put this validation code?

Regards,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:26:57+00:00Added an answer on June 8, 2026 at 9:26 pm

    I’ve used a base form with the error provider on and then had other forms inherit from this. I also put the visual error code in this base form also. This meant the same code is re-used. For Mvp, you could do something similar with a base form and an interface your application views inherit from. Your presenters would then see a uniform interface for setting validation states, messages, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to validate user input by using the QString::toDouble() function. The documentation says
I'm trying to validate user input on a text parameter using a VB function.
I am trying to validate user input in a form instantly using jquery. I
I am using jQuery Validator to validate user input. I am trying to figure
I'm trying to validate user input, which is just comma separated numbers. I'd like
I am trying to programatically validate a user login/pass using Spring Security, so I
I'm trying to write a regular expression that will validate that user input is
I'm trying to validate and get an interest rate from user input. I'm wanting
I'm trying to validate that the input a user gives my program via gets
I am trying to validate user input in WPF with Entlib 5.0. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.