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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:55:07+00:00 2026-05-24T06:55:07+00:00

how populate ComboBox and DataGridView using MVP (Model-View-Presenter). Actually i have something like this:

  • 0

how populate ComboBox and DataGridView using MVP (Model-View-Presenter). Actually i have something like this:

The View base class:

public interface IView
{
    event EventHandler Initialize;
    event EventHandler Load;
}

The presenter base class:

public class Presenter<TView> where TView : class, IView
{
    private TView view;
    public TView View { get { return view; } private set { view = value; } }

    public Presenter(TView view)
    {
        if (view == null)
            throw new ArgumentNullException("view");

        View = view;
        View.Initialize += OnViewInitialize;
        View.Load += OnViewLoad;
    }

    protected virtual void OnViewInitialize(object sender, EventArgs e) { }

    protected virtual void OnViewLoad(object sender, EventArgs e) { }
}

The specific view:

public interface IAdministrarUsuariosView : IView
{

    string NombreUsuarioABuscar {get; set;}

    List<Perfil> ListaPerfiles {get; set;}

    event EventHandler BuscarUsuarioPorNombre;
    event EventHandler BuscarUsuarioPorPerfil;
}

I don’t know how to populate the ComboBox and the Datagridview!

PD: Thanks to Josh for the code of the View and Presenter base classes (MVP Base Class)

Thanks!!

  • 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-24T06:55:08+00:00Added an answer on May 24, 2026 at 6:55 am

    you need to create a property that you will use to set up the data source for the ComboBox and DropdownList.

    just to give you an example(you need to improve this code but it shows a way on how you can do that)

    in you view :

    //this is just a template to simulate a datasource item
    public class TestItem
    {
        public int Id { get; set; }
        public string Description { get; set; }
    }
    
    public interface IAdministrarUsuariosView : IView
    {
    
        string NombreUsuarioABuscar { get; set; }
    
       // List<Perfil> ListaPerfiles { get; set; }
    
        event EventHandler BuscarUsuarioPorNombre;
        event EventHandler BuscarUsuarioPorPerfil;
        List<TestItem> SetComboBox { set; }
        List<TestItem> SetGridView { set; }
    
    }
    

    then in the concrete view (the winform that imolements the IAdministrarUsuariosView

    public class YourView:IAdministrarUsuariosView
    {
        public string NombreUsuarioABuscar
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }
    
        public event EventHandler BuscarUsuarioPorNombre;
        public event EventHandler BuscarUsuarioPorPerfil;
    
        public List<TestItem> SetComboBox
        {
            set
            {
                ComboBox.DataSource = value;
                //your need to specify value and text property
                ComboBox.DataBind();
            }
        }
    
        public List<TestItem> SetGridView
        {
            set
            {
                GridView.DataSource = value;
                //your need to specify value and text property
                GridView.DataBind();
    
            }
        }
    }
    

    then your presenter should look like the below:

    public class YourPresenter:Presenter<IAdministrarUsuariosView>
    {
    
        public YourPresenter(IAdministrarUsuariosView view) : base(view)
        {
        }
    
        protected override void OnViewLoad(object sender, EventArgs e)
        {
            List<TestItem> listResult = GetListItem();
            this.View.SetComboBox = listResult;
            this.View.SetGridView = listResult;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using code similar to this to populate a combobox with items from
Suppose we have a WPF ComboBox and want to populate it using ObjectDataProvider. <ObjectDataProvider
i have datagridview which has one combobox column. i populate combobox column. when i
I have a datagridview and a combobox which get populated randomly with data. However,
How could I populate a ComboBox (or a ToolStripComboBox like in the image) with
I'm trying to populate a ComboBox programatically. I am creating ComboBoxItems and would like
I would like to populate a combobox with the following: Visible item / Item
I am using currently the following code to populate a combobox: combobox.DataSource = datatable;
I have a populate combobox, and I'm so happy with it that I've even
Following is the code to populate combobox using DataSource Dim CountryList As Array =

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.