将列表(在对象中)数据绑定到VB.net中的组合框 [英] Databinding a list (in an object) to a combobox in VB.net
问题描述
VB 2008 .NET 3.5
我有一个包含ShippingRate对象列表的自定义Shipment对象。 ShippingRates的列表可通过Shipment.PossibleShippingRates属性访问。该属性仅返回该特定货件的ShippingRate列表的副本。
我的UI层从BLL接收装运对象的列表。这个列表是数据绑定到datagridview,并显示与装运地址等相关的详细信息,如运输地址等。
我想绑定Shipment.PossibleShippingRates组合框,这样当用户更改网格行时,组合框反映Shipment的PossibleShippingRates。
此外,我需要一种方法来存储ShippingRate,他们从组合框中选择以供以后使用。
我试过几个想法,但没有一个能正常工作。任何想法如何做这个?
不是最简单的解决方案是绑定一个TextChanged或SelectedIndexChanged事件任何/ datagrid中需要触发组合框刷新的所有字段?
VB 2008 .NET 3.5
I have a custom "Shipment" object that contains a list of "ShippingRate" objects. This list of "ShippingRates" is accessible through a property "Shipment.PossibleShippingRates." That property simply returns a copy of the list of "ShippingRate" for that particular Shipment.
My UI layer receives a list of "Shipment" objects from the BLL. This list is databound to a datagridview, and shows details relevant to the Shipment such as Shipping Address, etc.
I want to bind the "Shipment.PossibleShippingRates" property to a combobox, such that when the user changes the grid row, the combobox reflects the "PossibleShippingRates" for that "Shipment."
In addition, I need a way to store the "ShippingRate" they selected from the combobox for later use.
I have tried a few ideas, but none of them work properly. Any ideas on how to do this?
Wouldn't the simplest solution be to tie a TextChanged or SelectedIndexChanged event to any/all fields in the datagrid that need to trigger a refresh of the combobox?
这篇关于将列表(在对象中)数据绑定到VB.net中的组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!