R
Richard Myers
Hello.
Im stumped over the following behaviour.
I want to trigger an update of some related form fields when a sales
territory combo is updated. Ive found that if the selectedindex already = 0
and i .selectedindex = 0 then the selectedvalue is not updated. I assume
selectedvalue is only updated OnSelectedIndexChanged not just when this
property is set?
So my current work around is setting the .selctedindex = -1 then the
following staement .selectedindex =0.
However this is stupid code. So then i thought i'd set the datasource to
nothing as below.
With Me.cboTerritory
.DataSource = Nothing
.DataSource = _validCustomerTerritories.SalesTerritory
.ValueMember = "SalesTerritoryId"
.DisplayMember = "TerritoryName"
_bindingTerritory = False
If .Items.Count > 0 Then .SelectedIndex = 0
End With
However, and this relates to my question, in doing this .selectedindex=0 is
never fired because .items.count is never > 0, even though
_validCustomerTerritories.SalesTerritory has more than 15 items in it?
If i take out out .Datasource = Nothing then .Items.Count = 15 but then as
above .SelectedIndex = 0 doesn't trigger the update because .SelectedIndex
ws already 0. I dont understand why setting the .Datasource to "nothng"
before setting it too "something with a positive count" screws up the .items
collection count?
I can work around it with an extra statement or but i dont think i should
have too.
Any ideas?
TIA
Richard
Im stumped over the following behaviour.
I want to trigger an update of some related form fields when a sales
territory combo is updated. Ive found that if the selectedindex already = 0
and i .selectedindex = 0 then the selectedvalue is not updated. I assume
selectedvalue is only updated OnSelectedIndexChanged not just when this
property is set?
So my current work around is setting the .selctedindex = -1 then the
following staement .selectedindex =0.
However this is stupid code. So then i thought i'd set the datasource to
nothing as below.
With Me.cboTerritory
.DataSource = Nothing
.DataSource = _validCustomerTerritories.SalesTerritory
.ValueMember = "SalesTerritoryId"
.DisplayMember = "TerritoryName"
_bindingTerritory = False
If .Items.Count > 0 Then .SelectedIndex = 0
End With
However, and this relates to my question, in doing this .selectedindex=0 is
never fired because .items.count is never > 0, even though
_validCustomerTerritories.SalesTerritory has more than 15 items in it?
If i take out out .Datasource = Nothing then .Items.Count = 15 but then as
above .SelectedIndex = 0 doesn't trigger the update because .SelectedIndex
ws already 0. I dont understand why setting the .Datasource to "nothng"
before setting it too "something with a positive count" screws up the .items
collection count?
I can work around it with an extra statement or but i dont think i should
have too.
Any ideas?
TIA
Richard