문제

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
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top