我有一个带有2种窗体的Winform应用程序,ParentForm和ChildForm。我想将一个类的列表从ParentForm传递给ChildForm,然后将新项目添加到childform的列表中。用户按下子窗体中的按钮后,应将非常相同的列表传递回ParentForm,并触发一个事件,以便我可以在ParentForm中基于该列表更新计数器。我试图实现这样的Inotify事件。
public static void DataUpdated_propertyChanged(object sender, PropertyChangedEventArgs e)
{
UpdateCounter();
}
public static void UpdateCounter()
{
btnCounter.Text = TeamList.Count().ToString();
}
但是btnCounter给我这个错误。 “非静态字段需要对象引用”
该如何解决?还是应该采用其他方法?