我正在尝试使用反射获取表单的 BindingSource。以下代码是我迄今为止尝试过的,尽管它有错误:
public class MyClass :Form
{
BindingSource bs = new BindingSource();
}
public static class Class2
{
public static BindingSource GetBindingSource(string FieldNameP, Form FormP)
{
BindingSource Bs = null;
var info=FormP.GetType().GetField(FieldNameP);
if(info != null)
{
Bs = (BindingSource)info.GetValue(null)
}
return Bs;
}
}