I've got a window with multiple datagridviews. Each with data from a separate dataTable. All of which are part of the same DataSet. There are a couple of places where one DataTable has a field joined with the lookup dataTable from the dataset. For example a lookup table for LugSizes has a field called LugSize that is also it's primary key. Another table called Device Terminations has a field called LugSize to which the user can only select those values from the LugSize lookup table. I thought it would be as simple as using the Items.Add method for the combobox column whenever a new lookup table row was added to its own datagridview. Unfortunately, when I try to initially clear the items list, the data error event is triggered for every row. Is this the wrong approach?
Here's a sample of my code if it helps:
Any help would be appreciated.HTML Code:Private Sub FillLugSizeComboBox() Try If colDTLugSize.Items.Count > 0 Then colDTLugSize.Items.Clear() If colTBLugSize.Items.Count > 0 Then colTBLugSize.Items.Clear() For Each recLugDim As DataRow In dbSettings.LugDimension.Table.Rows colDTLugSize.Items.Add(recLugDim.Item("LugSize")) colTBLugSize.Items.Add(recLugDim.Item("LugSize")) Next dgvDeviceTermDef.Refresh() dgvTBPanelDef.Refresh() Catch ex As System.Exception MessageBox.Show("Error Filling LugSize ComboBox" & vbCrLf & Err.Source & vbCrLf & _ "Error Number: " & Err.Number & vbCrLf & ex.Message, _ "WireShopAutomation: Advanced Options Dialog", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Private Sub dgvLugDimensions_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgvLugDimensions.CurrentCellChanged If dgvLugDimensions.IsCurrentRowDirty Then dgvLugDimensions.BindingContext(dbSettings.LugDimension.Table).EndCurrentEdit() FillLugSizeComboBox() btnApply.Enabled = True End If End Sub




Reply With Quote
