lunaclover
Programmer
- Jun 22, 2005
- 54
Hi - Here's what I'm trying to do, as you all may know by now having read my 9 million threads. I am connecting to a sql db and have several tables. Each table is connected to its own combobox. Depending on what a user selects for combobox2, for example, I want combobox4 to remove some of its selections, since certain combinations of options in combobox2 and in combobox4 aren't valid. If the user changes his/her selection in combobox2, the options need to reappear in combobox4. There are a million and one business rules I am trying to work with.
Here's my code, which of course isn't working.
It says
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: Cannot modify the Items collection when the DataSource property is set.
How should I go about this? I can't figure this out. I just want to really 'hide' it, so that way I won't have to replace a whole record later, which I really dont' know how to do.
Thanks for your help,
Luna
Here's my code, which of course isn't working.
Code:
Private Sub Infusion()
If combobox2.ValueMember = "B" Or combobox2.ValueMember = "W" Then
combobox4.Items.Remove("210")
combobox4.Items.Remove("-18")
Else
'checks for values present so as not to duplicate
If combobox4.Items.Contains("210") Or combobox4.Items.Contains("-18") Then
'nothing
Else
combobox4.Items.Add("210")
combobox4.Items.Add("-18")
End If
End If
End Sub
It says
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: Cannot modify the Items collection when the DataSource property is set.
How should I go about this? I can't figure this out. I just want to really 'hide' it, so that way I won't have to replace a whole record later, which I really dont' know how to do.
Thanks for your help,
Luna