Databinding a list (in an object) to a combobox in VB.net

99封情书 提交于 2019-12-24 22:26:26

问题


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?


回答1:


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?



来源:https://stackoverflow.com/questions/2043397/databinding-a-list-in-an-object-to-a-combobox-in-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!