Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为什么可以';是否访问窗体的公共System.Windows.Forms.BindingSource?_C#_Winforms - Fatal编程技术网

C# 为什么可以';是否访问窗体的公共System.Windows.Forms.BindingSource?

C# 为什么可以';是否访问窗体的公共System.Windows.Forms.BindingSource?,c#,winforms,C#,Winforms,我有一个由VS as创建的带有绑定源的form1 private System.Windows.Forms.BindingSource bindingSource1 我已经从私人变为公共 Sill Intellisence无法识别 form1.BindingSource 在另一个表格内2 Form1 form1 = new Form1(); form1.bindingSource1 = ...; 为什么?您没有显示字段的名称-仅显示类型。例如,它可能是: public System.Win

我有一个由VS as创建的带有绑定源的form1

private System.Windows.Forms.BindingSource bindingSource1
我已经从私人变为公共

Sill Intellisence无法识别

form1.BindingSource
在另一个表格内2

Form1 form1 = new Form1();
form1.bindingSource1 = ...;

为什么?

您没有显示字段的名称-仅显示类型。例如,它可能是:

public System.Windows.Forms.BindingSource bindingSource1;
您还需要确保
form1
变量的类型正确(而不仅仅是
Form
)。如果你能给出一个简短但完整的例子,那会有所帮助


但就个人而言,我会避免将字段公开-如果确实需要公开绑定源,请使用属性访问它。

在这个特定示例中,BindingSource是成员的类型。从您的样本中不清楚该成员的姓名。因此,您可能实际上绑定到了错误的名称

您是对的,但我在问题中犯了一个错误,因此我更正了。但是它不起作用。再一次,一个简短但完整的例子会有所帮助。如果该字段是真正公开的,那么您得到的代码看起来会起作用。您收到了什么错误消息?