数据源的传递参数 [英] passing parameter of datasource

查看:174
本文介绍了数据源的传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在代码中:

In code:

TransportBindingSource.DataSource  =db.Transports;


如何将db.Transports保存到公共变量并将其用作
的数据源


how can save db.Transports to a public variable and use it as datasource of
other object in other form?

推荐答案

using System.Linq;
using System.Collections.Generics;





var source = db.Transports;
TransportBindingSource.DataSource =source ;





Ilist list = source.ToList(); 




可以帮助您吗?




could help ?


您应该创建一个单独的静态类来保存您的数据信息,以使其与Form类分开.这样,您创建的任何UI类都将能够获取数据.如果您的数据对象包含在一个表单类中,那么解决方案的设计就很简单.
You should create a separate static class that holds your data information so that it is separate from your Form classes. That way, any UI class you create will be able to get at the data. If your data object is included in one of the form classes, then there is quite simply a problem with the design of the solution.


这篇关于数据源的传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆