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

  • Home
  • SEARCH
  • 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 1000221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:28:44+00:00 2026-05-16T07:28:44+00:00

I have a WinForm and few properties that are set on it. for example

  • 0

I have a WinForm and few properties that are set on it.
for example : Name,Address are accepted on the Form.
(many more properties in actual example)

The current implementation is somewhat similar to

frmName frmView = new  frmName (); //frmName  is WINFORM 
frmView.Name= "ABC"; //any valid string or read this from file
frmView.Address="SomeAddress"; //any valid address or read this from file

if (frmView.ShowDialog() == DialogResult.OK)
{
    //OK CLICK PROCESS and
    // get new values edited by user
     string name = frmView .Name;
     string address = frmView.Address;
     doProcessing(name,address);
}
else{
  //Ignore cancel click..
}

how do i convert this to a MVP based Winform application.
Also need to refactor the processing done on ShowDialog() to the Presenter/Model
(dunno exactly where to do it)?
Also need to avoid writing code on the form itself.(Passive view)

Thanks All.

  • 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-05-16T07:28:44+00:00Added an answer on May 16, 2026 at 7:28 am

    I’m still experimenting with different MVP approaches myself, but the way I’m currently doing it is like so:

    frmName frmView = new frmName();
    
    if (frmView.ShowDialog() == DialogResult.OK) {
        presenter.RequestProcessing(frmView.Name, frmView.Address);
    } else {
        //Ignore cancel click..
    }
    

    You say you want to avoid writing any code on the form itself, but this doesn’t make sense to me. In Passive View, you pass on all application-specific requests to the controller or presenter.

    In this example, the view handles view-related logic. Opening the dialog box isn’t a user action that anything else (such as the presenter) needs to be informed about. Just like opening a context menu, a dialog box is part of how this particular view chooses to offer those application-specific requests to the user. Until the user actually goes through with it and submits the request, the presenter doesn’t need to know anything.

    In some circumstances where I’ve needed to be able to handle errors within the dialog box itself, I’ve passed the IPresenter object into the dialog box’s constructor. It can then make the appropriate presenter request itself when the “OK” button is clicked, for example, and can show a message box instead of closing in case of an error.

    There are a lot of variations on MVP, but I hope this helps. Good luck with setting it up.

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

Sidebar

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.