Why can't I access the public System.Windows.Forms.BindingSource of a form?
I开发者_如何转开发 have a form1 with a binding source created by VS as
private System.Windows.Forms.BindingSource bindingSource1
I have changed private to public
Sill Intellisence doesn't recognize
form1.BindingSource
within another form2
Form1 form1 = new Form1();
form1.bindingSource1 = ...;
Why ?
You haven't shown the name of the field - only the type. For instance, it might be:
public System.Windows.Forms.BindingSource bindingSource1;
You also need to make sure your form1
variable is of the right type (rather than just Form
). If you could give a short but complete example, that would help.
Personally I would avoid making the fields public though - if you really need to expose the binding source, use a property to access it.
In this particular example, BindingSource is the type of the member. It's not clear from your sample what the name of the member is. So you can in effect be binding to the wrong name
精彩评论