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 9242147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:31:18+00:00 2026-06-18T08:31:18+00:00

I have a WinForms application implemented in MVP. My form has a TextBox and

  • 0

I have a WinForms application implemented in MVP. My form has a TextBox and I want to databind its Text property to a property in the Model. I don’t want to refer to the Model in the View.

After searching in Google, I found that databinding by coupling Model and View is a bad idea. My sample initialization of Model, View and Presenter is as follows.

class View : Form, IView
{
    public View()
    {
        InitializeComponent();
        new Presenter(this);
    }
}

class Presenter
{
    public Presenter(IView) : this.Presenter(this, new Model())
    {
    }

    public Presenter(IView view)
    {
    }
}

class Model : IModel
{
    public Model()
    {
    }

}

At present I have 3 projects each for Model, View and Presenter. View has reference to Presenter and Presenter has reference to Model. Can anyone guide me how to form a databinding to a control in View to a property in Model?

EDIT

I know to do the things in Grid. We can assign Datasource property of grid to a List (or something similar) in presenter like:

_view.DataSource = _model.ListOfEmployees;

This will reflect the value in UI when ListOfEmployees changes in the Model. But what about a TextBox which exposes a Text property? How can I bind that in MVP architecture?

  • 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-18T08:31:19+00:00Added an answer on June 18, 2026 at 8:31 am

    My recommendation is to encapsulate the View and Model in the Presenter. This means a specialized Presenter (in most cases) for a given View. In my opinion, this works out well since most Models will be different anyway.

    class Presenter {
        readonly IView view;
        readonly IModel model;
    
        public Presenter() {
            // if view needs ref. to presenter, pass into view ctor
            view = new View(this);
            model = new Model();
        }
    
        // alternatively - with the model injected - my preference
        public Presenter(IModel Model) {
            // if view needs ref. to presenter, pass into view ctor
            view = new View(this);
            model = Model;
        }
    }
    

    In your IView, expose a control or control’s data source property:

    interface IView {
        object GridDataSource { get; set; }
    }
    

    Add to your Presenter some method:

    void SetGridDatasource() {
        view.GridDatasource = model.SomeBindableData;
    }
    

    View implementation:

    public object GridDatasource {
        get { return myGridView.DataSource; }
        set { myGridView.DataSource = value; }
    }
    

    Note:
    Code snippets are untested and recommended as a starting point.

    Update to comments:
    INotifyPropertyChanged is a very valuable mechanism for updating properties between IView and IModel.

    Most controls do have some sort of binding capability. I would recommend using those DataBinding methods whenever possible. Simply expose those properties through IView and let the Presenter set those bindings to the IModel properties.

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

Sidebar

Related Questions

I have a WinForms application, with login form, and I want to store the
i've made a C# winforms application. Now i have a form which has lots
I have WinForms application. My Form derived class has UserControl derived class. I simply
I have a Winforms application that generates its own PrintDocument object for printing. It
We have a WinForms application that uses SQL server to store its data. To
Scenario I have a C# WinForms application with a main form. I also have
I have a WinForms Application that I want to run at Mono at some
I have implemented the MVP pattern in a few WinForms applications that uses a
My program class has: Application.Run(new Form1()); in form1 class I have: model = new
I have a Winforms application (written in C#) that is deployed on a network

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.