找回密码
 FreeOZ用户注册
查看: 2615|回复: 0
打印 上一主题 下一主题

[论坛技术] Using Linq for Master Detail in a DataGridView

[复制链接]
跳转到指定楼层
1#
发表于 8-7-2008 03:51:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
提示: 作者被禁止或删除, 无法发言

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?FreeOZ用户注册

x
Windows Forms Data Controls and Databinding

Step 1

         Open up Visual Studio 2008 Beta 2 and create a windows forms application

Step 2

         Add a new Linq to Sql classes to the project I named mine Northwind.dbml

Step 3

        I dragged the Northwind databases Orders and Order Details tables on the surface

Step 4

        Save the project and build it

Step 5 这一步是关键

       Open the datasources window and add a new object data source.  Select the Orders table

Step 6

        Drag the orders table on your windows form

Step 7

        Drag the orders_details table on the form

Step 8

        In the form load event add this code
  1. private void Form1_Load(object sender, EventArgs e)
  2. {
  3.         NorthwindDataContext db = new NorthwindDataContext();
  4.         orderBindingSource.DataSource = from o in db.Orders select o;
  5. }
复制代码
原文:
http://forums.microsoft.com/MSDN ... 019272&SiteID=1

这么容易就建立了一个主从表界面,厉害!

[ 本帖最后由 xblues 于 8-7-2008 01:53 编辑 ]
回复  

使用道具 举报

您需要登录后才可以回帖 登录 | FreeOZ用户注册

本版积分规则

小黑屋|手机版|Archiver|FreeOZ论坛

GMT+10, 19-5-2024 14:18 , Processed in 0.012525 second(s), 17 queries , Gzip On, Redis On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表