[英]How to make other controls see a collection of DataTables in a custom control?
I am building a custom compoment that can be dragged from the toolbox onto a form.我正在构建一个可以从工具箱拖到表单上的自定义组件。
It exposes a List of type DataTable, and this works well so far.它公开了一个 DataTable 类型的列表,到目前为止效果很好。
What I am missing is that when I put a BindingSource on the same form, in the designer the BindingSource does not see my collection of DataTables.我缺少的是,当我将 BindingSource 放在同一个表单上时,在设计器中 BindingSource 看不到我的 DataTables 集合。 So I cannot select one of the DataTables from the custom component.
所以我不能 select 来自自定义组件的 DataTables 之一。 I know I can do this in code but that is not the idea, I want to do it in the designer.
我知道我可以在代码中做到这一点,但这不是我的想法,我想在设计器中做到这一点。
How can I accomplish this?我怎样才能做到这一点?
The code for the public collection of DataTables is this DataTables 的公共集合的代码是这样的
[Serializable]
public partial class gttDataModule : Component
{
private List<DataTable> _dataTables = new List<DataTable>();
public List<DataTable> DataTables
{
get { return _dataTables; }
set { _dataTables = value; }
}
The collection of DataTables is populated and filled with columns and everything, see also the attached image. DataTables 的集合被填充并填充了列和所有内容,另请参见附图。
Everything works except that BindingSources and other controls that can accept a DataTable as DataSource do not see this collection.一切正常,除了 BindingSources 和其他可以接受 DataTable 作为 DataSource 的控件看不到这个集合。
Is there a way to accomplish this?有没有办法做到这一点?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.