Hi I have problem with a datagridview with combo boxes firing unwanted events handlers.
I have a datagridview with 4 columns all data bound. All of these columns have comboboxes. Column 2,3,4 has a custom generated combobox with code with on the 'DataGridView_EditingControlShowing event' and have event handlers (Dropdown,selected Etc). (Data in the custom generated comboboxes needs to be filtered and worked on)
The problem is if i select a column with a combobox (Col 2 or 3 or 4) that i have generated THEN select a column on the datagrid that i have not generated Col 1 the event handler (Dropdown) from the previous generated combobox is fired.Code:Friend WithEvents ComboBoxPowerPlantSelect As System.Windows.Forms.ComboBox Friend WithEvents ComboBoxAttachment1 As System.Windows.Forms.ComboBox Friend WithEvents ComboBoxAttachment2 As System.Windows.Forms.ComboBox Private Sub TblMachineCombinationListDataGridView_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles TblMachineCombinationListDataGridView.EditingControlShowing Select Case ColumnSelected Case 3 : ComboBoxPowerPlantSelect = TryCast(e.Control, ComboBox) 'generate the combobox MachinePowerPlantSelected() Case 4 : ComboBoxAttachment1 = TryCast(e.Control, ComboBox) 'Generate the combobox Attachment1Selected() Case 5 : ComboBoxAttachment2 = TryCast(e.Control, ComboBox) 'Generate the combobox Attachment2Selected() Case Else : Exit Sub End Select End Sub
How do i stop this, or what is the best way of disposing of the previously used combobox that i have generated after the user has selected the data in the combobox.
I don't know where to put the ComboBoxPowerPlantSelect.dispose() method to handle this properly in my code
Cheers




Reply With Quote
