Separating Combo Boxes with Similar Data
A situation came up where a Windows Forms application required 2 combo boxes filled with customer IDs. A caption of that form is shown below, where a user must select “From Customer ID” and “To Customer ID”. Since both combo boxes were populated from the same data column, the natural thing to do was to use the same code for filling both with the same data. However, this caused an undesirable effect. When the user selected the “From Customer ID”, the “To Customer ID” was automatically populated with the same value. To resolve this problem, 2 separate DataTable objects must be used, dtFrom and dtTo. Although both objects are populated using the same method (dm.GetCustomerIDNames()), keeping the objects separate will prevent one control selection from effecting the other control. See sample code shown below. p...