Re: Combobox Binding Problem

Re: Combobox Binding Problem

Old forum URL: forums.lhotka.net/forums/t/1223.aspx


GinoK posted on Wednesday, September 13, 2006

Brian,

No joy there, the text field is blank and I removed refernces from the databindings text property also as I read on previous forums that should be blank.

The Combobox is set up as follows:

# From my  initialization code :

Me.CurrencyNVListBindingSource.DataSource = CurrencyNVList.GetList()

cboCurrency.DataSource = CurrencyNVListBindingSource
cboCurrency.DisplayMember = "Value"
cboCurrency.ValueMember = "Key"
cboCurrency.DataBindings.DefaultDataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged

(Apart from the population of the NVL most of the above appears to be irrelevant as it would have been set from the designer, I have tried the code with the line in or ommited with no change in results)


# Passed From Windows Form Designer i.e Initialize Component

'
'cboCurrency
'
Me.ReadWriteAuthorization1.SetApplyAuthorization(Me.cboCurrency, True)
Me.cboCurrency.DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", Me.ControlCompanyBindingSource, "CurrencyID", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged))
Me.cboCurrency.DataSource = Me.CurrencyNVListBindingSource
Me.cboCurrency.DisplayMember = "Value"
Me.cboCurrency.FormattingEnabled = True
Me.cboCurrency.Location = New System.Drawing.Point(158, 141)
Me.cboCurrency.Name = "cboCurrency"
Me.cboCurrency.Size = New System.Drawing.Size(121, 24)
Me.cboCurrency.TabIndex = 46
Me.cboCurrency.ValueMember = "Key"
'
'CurrencyNVListBindingSource
'
Me.CurrencyNVListBindingSource.DataSource = GetType(Csla.NameValueListBase(Of Integer, String).NameValuePair)
Me.BindingSourceRefresh1.SetReadValuesOnChange(Me.CurrencyNVListBindingSource, False)

'

'ControlCompanyBindingSource

'

Me.ControlCompanyBindingSource.DataSource = GetType(Adsell.Library.BTier.ControlCompany)

Me.BindingSourceRefresh1.SetReadValuesOnChange(Me.ControlCompanyBindingSource, True)


 

I based application on some of Rocky's ideas in his book. The form uses the BindingSourceRefresh which can also cause behaviour of combo to vary. For example if the BusinessBase binding source has the property ReadValuesOnChange on binding is set to true, immediately I select an item from the list the underlying SelectedValue is set but the ComboBox displays nothing. If this property is set to false the Underlying Property appears to be set but the ComboBox displayed text remains visible until I tab from the control.

Regardless of which way I work the underlying logic of the code appears to be working but the visual aspect would make it unworkable as an application from a user's perspective.

By the way I am using Visual 2005 with .net 2.0 if that has any bearing.

I also had a similar problem on a Datagrid using a NVL in one of the columns with a root collection and again while it appeared to set the value the display from the NVL cleared on exiting. When compared to the latest textbook from Rocky on his implementation of resource in the Project it appeared to be coded in a similar fashion but mine didn't work. The ptracker project however bahaved as expected on my PC.

 

Thanks

 

Ian

Copyright (c) Marimer LLC