[英]custom-made UserControl property binding in WinForms
I've a custom-made user control:我有一个定制的用户控件:
public class CustomUC : UserControl
{
[Bindable(true)]
private string PropertyX { get { ... } ; set { ... }; }
}
I'm using it from another form.我正在从另一种形式使用它。 On this form I'm using a DataSource.
在这个表单上,我使用了一个数据源。
The problem is that I'm unable to figure out how to bind this PropertyX
to some field of my DataSource.问题是我无法弄清楚如何将此
PropertyX
绑定到我的数据源的某个字段。
EDIT编辑
My DataSource
is a System.Windows.Forms.BindSource
object I've created on design-time.我的
DataSource
是我在设计时创建的System.Windows.Forms.BindSource
对象。 I've set a class to this datasource
in order to be linked to a ClassA
.我已经为此
datasource
设置了一个类,以便链接到ClassA
。 This class has a property Notes
I'd like to bind to CustomMadeUCPropertyX
...这个类有一个属性
Notes
我想绑定到CustomMadeUCPropertyX
...
您应该尝试以下方式通过编码绑定属性:
object.DataBindings.Add("PropertyX", YourDataSrouce, "columnname in your datasource")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.