VB.NET 2008 .NET 3.5
Using WinForms.
I have a class that is bound to a DataGridView through a BindingSource. This class contains a List as one of it's properties. The List contains another custom class. Both classes are part of an automated shipping program:
Class OrderShipment
Public Property OrderID as String
Get
Set
End Property
Public Property AvailableBoxes as List(of Boxes)
Get
Set
End Property
End Class
I have the List "AvailableBoxes" databound to a DataGridViewComboBoxColumn. The user will select a "Box" from the list.
I need to store the selected "Box" in the OrderShipment class. I have two solutions to this, but am looking for other suggestions/improvements:
1) Handle the DataGridView.EditingControlShowing Event. Evidently this is the only way to get access to the ComboBox Events. You have to Handle the EditingControlShowing Event, cast to a ComboBox, then you have access to the regular ComboBox Events. The selected value could be stored in another property inside OrderShipments.
2) Same as #1, except create a "Selected as Boolean" property for the "Boxes" Class. Set this property to true instead of creating a new property in OrderShipments.
Both of my solutions require the funky Event Handling required to get DataGridViewComboBox Events. The BindingSource obviously knows which Item from "AvailableBoxes" is selected. Is there a better way to set/store the selected value?