2 Entites,但如何显示这些关系? [英] 2 Entites,but how to show these relationships?

查看:147
本文介绍了2 Entites,但如何显示这些关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


OrderEntity:


Guid _OrderID;


DateTime _OrderName;


IList< DetailOrderEntity> _DetailOrders;


......



DetailOrderEntity:


Guid _OrderID;


string _ProductID;


十进制_Price;


十进制_Acount;


......



代码:


OrderEntity OE = new OrderEntity();


Guid guid = Guid.NewGuid();


OE.OrderID = guid;


OE .OrderName = DateTime.Today;



DetailOrderEntity DOE = new();


DOE.OrderID = guid;


DOE.ProductID =" P1";


DOE .Price = 12.00M;


DOE.Amount = 12.00M;



< p align = left> OE.DetailOrders.Add(DOE);


............



我想笑数据就像使用DataSet.Relation一样,dataGridView可以显示"+",然后单击"+"。可以扩展。


但它无法显示!


谢谢!

解决方案

WinForms DataGridView不支持显示层次记录/行。

作为替代方案,您可以使用两个网格。一个是显示OrderEntity项目的主网格,另一个是显示与主网格中当前选定的OrderEntity项目相关的DetailOrderEntity项目的详细网格。


 

OrderEntity:

Guid _OrderID;

DateTime _OrderName;

IList<DetailOrderEntity> _DetailOrders;

......

 

DetailOrderEntity:

Guid _OrderID;

string _ProductID;

decimal _Price;

decimal _Acount;

......

 

Code:

OrderEntity OE = new OrderEntity();

Guid guid = Guid.NewGuid();

OE.OrderID = guid;

OE.OrderName = DateTime.Today;

 

DetailOrderEntity DOE = new ();

DOE.OrderID = guid;

DOE.ProductID = "P1";

DOE.Price = 12.00M;

DOE.Amount = 12.00M;

 

OE.DetailOrders.Add(DOE);

............

 

I wanna show the datas just like use DataSet.Relation,the dataGridView could show "+",then click the "+" can expand.

but it can't show that!

thanks!

解决方案

The WinForms DataGridView does not support the display of hierachical records/rows.

 

As an alternative, you could use two grids.  One is the master grid to display OrderEntity items, and the other is the detail grid to display DetailOrderEntity items related to the currently selected OrderEntity items in the master grid.


这篇关于2 Entites,但如何显示这些关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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