I am a nooby trying to learn mvc in C# winforms, but I cant seem to understand why my instance turns null on me.
View Form
public partial class Form1 : Form, ISingleTagProperties
{
.....
PropController _propController;
public void SetController(PropController controller)
{
_propController = controller;
}
.....
private void dataGridView3_CurrentCellChanged(object sender, EventArgs e)
{
_propController.updateProperites(dgv);
}
Edit:Calling updateProperties is what gives me the null reference.
Controller PropController class
public class PropController
{
SingleTagProperties _view;
//constructor
public PropController(SingleTagProperties view)
{
_view = view;
view.SetController(this);
}
......
View Instance ISingleTagProperties
public interface ISingleTagProperties
{
void SetController(PropController controller);
string TagName { get; set; }
string TagDescription { get; set; }
.....
SetController fires and _propController comes out not null, but then further down in the form trying to call a method from the PropController class gives a NullReferenceException saying that _propController is null.
There's probably some basic understanding I am missing somewhere, but I can't seem to figure it out.