将DataSource属性添加到自定义WinForms控件 [英] Add DataSource Property to a Custom WinForms Control
本文介绍了将DataSource属性添加到自定义WinForms控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想添加复杂的数据绑定到我的自定义winforms控件,所以我可以做以下:
I want to add complex databinding to my custom winforms control, so I can do the following:
myControl.DisplayMember = "Name";
myControl.ValueMember = "Name";
myControl.DataSource = new List<someObject>();
有没有人知道要实现什么接口等?
does anyone know what interfaces, etc. have to be implemented to achieve this?
我已经看过,我发现所有的都是 IBindableComponent
,但这似乎是简单绑定而不是复杂绑定
I've had a look into it and all I found is IBindableComponent
, but that seems to be for Simple Binding rather than Complex Binding.
推荐答案
您的类需要继承DataBoundControl类而不是UserControl。
Your class needs to inherit the DataBoundControl class instead of UserControl.
这篇关于将DataSource属性添加到自定义WinForms控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文