Hopefully this image is readable on here...
This is my first project implementing MVP. I've got three classes. My main form, aptly named FrmMain
, FrmMainPresenter
, and then MainOps
which has some extra stuff.
On FrmMain
, I've got a reference to FrmMainPresenter
, and on FrmMainPresenter
I have a reference to FrmMain
.
An event on FrmMain
calls a method on FrmMainPresenter
.
FrmMainPresenter
is supposed to get a control from the FrmMain
reference and call a method on MainOps
that accepts a GridControl
and Collection<Control>
.
However, upon trying to access the appropriate Grid and Collection within FrmMainPresenter
, it tells me FrmMain
doesn't contain a definition for those controls
Code on FrmMain
:
private void genericCheckbox_CheckedChanged(object sender, EventArgs e)
{
_presenter.CheckBoxCheckedChanged();
}
Code on FrmMainPresenter
:
public void CheckBoxCheckedChanged()
{
if (!_view.SuppressCheckedChanged)
_mo.UpdateFilter(_view.gdcSVNDefaultView, _view.Controls);
}
Not sure what I'm doing incorrectly. I didn't think this was correct, but my only guess was to go and set the necessary controls to public in the Designer file, but that didn't work. Same results.
I guess the issue is because the interface for my form doesn't have the gridview / controls collection defined, my presenter class can't see it. But even then I'm not sure how I'd properly define it in the interface so that I could implement it on the form.
You can either make the Control
in FrmMain
public through the designer properties or add a public getter to the FrmMain
code which the FrmMainPresenter
can then access.
There are probably another half dozen ways this can be ultimately achieved but these are probably the 2 most common and easiest ways to do achieve your goal.