1

I have cascading data-bound combo boxes, however, if the second of the two boxes does not have the value, I am trying to change the data source of the original process to the default selection.

However I am getting errors no matter what I try to do to get the combo box to clear.

    cboSubSystem.SelectedIndex = -1
    cboSubSystem.DataSource = Nothing
    Call cboSubSystem.Items.Clear()

    cboSubSystem.DataSource = oSubSystem.EntityList
    cboSubSystem.DisplayMember = oSubSystem.ORM.SubSystem_c
    cboSubSystem.ValueMember = oSubSystem.ORM.SubSystem_c

I also tried the double set for SelectedIndex like http://support.microsoft.com/default.aspx?scid=kb;en-us;327244

What am I doing wrong? I am sure it is something simple but I cannot get past this.

Thanks in advance.

EDIT:

  • EntityList is a generic list for a DTO
  • The dropdowns are using different data sources, when this one is set, I just call the sub routine to load the other one.
  • Errors:
    • Currently: "Items collection cannot be modified when the DataSource property is set." at the Items.Clear
    • If I try to remove the clear, I get "Cannot bind to the new value member. Parameter name: value" at the valuemember set
RiddlerDev
  • 7,370
  • 5
  • 46
  • 62
  • What errors do you get and where do you get them? What type is oSubSystem and its properties EntityList and ORM+SubSystem_c? Show us some source code. – Tim Schmelter Dec 28 '10 at 00:43
  • 1
    How have you implemented the cascading data-bound combo boxes? Where is the relation, do both comboboxes use the same datasource? – Tim Schmelter Dec 28 '10 at 00:51
  • The ORM is just the string value of the column name for the DTO, in this case just "SubSystem_c" – RiddlerDev Dec 28 '10 at 14:28
  • Looking at it more... even if I set the datasource = nothing it is still set to the old source... even tried clearing the databindings. – RiddlerDev Dec 28 '10 at 15:19

1 Answers1

1

Found my problem. There was an event routine for index changed that loaded the second combo box. That combo box used the selected index, and apparently that locked the data source enough that I could not clear it. Was able to fix it with a re-arrangement of the refresh process.

RiddlerDev
  • 7,370
  • 5
  • 46
  • 62