Binding to Janus ComboBox headache

Posts   
 
    
Jax
User
Posts: 8
Joined: 16-May-2005
# Posted on: 21-Sep-2005 01:34:37   

Hi Otis,

I have a binding issue that I need assistance with - typically with combo boxes. I've tested the issue with a standard VS2005 ComboBox and Janus ComboBox and they both exhibit the same problem so I'm hoping your deeper experience can shed some light on the problem.

The form in question contains a large number of controls - Janus textboxes, comboboxs, grids and tabs etc. and is used to display member information.

The form is instantiated using:

Dim newForm as New MemberDataForm newForm.Open(entityId)

The form's Open methods are:

Public Overrides Sub Open(Byval entityId as System.Guid) ' GetMember returns a Member Entity object for a given entityId. Me.Open(MemberData.GetMember(entityId, True)) End Sub

Public Overrides Sub Open(Byval entityObject as EntityBase2) ' Sets up data binding using a call to a BindField method in the base form using ' BindField(control?, BindableValue?, DataField?) format. ' ... and is repeated for each bound field on the form. End Sub

The New constructor of the form initialises icons from the resource file and populates the 'to be bound' combo box called cboStatus thus:

With cboStaus .ValueMember = "LookupValue" .DisplayMember = "LookupValue" .DataSource = LookupData.GetLookupList("MEMBERSTATUS") .SeletedValue = "" End With

Ok, when the application is run and this Member form is initialised and passed an entityId, the member entity is retrieved fine and after the binding operation completes and the form is displayed there is no value shown in the cboStatus combo box. The combo box when dropped down contains the correct lookup list values.

Bare in mind that all these binding operations are called prior to showing the form.

When I place a me.show before the first binding operation all of the fields and combo boxes show the right values. With the me.show after the binding operations, the combobox value is blank.

During my stepping through the code I observed that two properties of the cboStatus combobox - namely cboStatus.DataBindings(0).IsBinding and cboStatus.DataBindings(0).BindingManagerBase - have different values.

When it binds correctly and shows the value, these properties contain True and System.Windows.Forms.PropertyManager respectively. When they don't bind correctly, they contain False and Nothing respectively.

Any advice would be very much appreciated

Thanks in advance Neil

Jax
User
Posts: 8
Joined: 16-May-2005
# Posted on: 21-Sep-2005 01:49:47   

I forgot to mention that the majority of the application works using the same principles as described above.

I've just begun going through the application deriving lookup list data from the database instead of using hard-coded lists (some developers eh!!) and have implemented the same solutionon of the smaller forms and there are no problems.

It seems to be as a result of it being a rather fat form?

Thanks again...

PS. we're using VS2005 RC1.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 21-Sep-2005 10:31:01   

WHen you call the binding functionality from the Form Load event handler (OnLoad) does it work then? I had strange results with databinding too (not entity related) sometimes when I bound from the form constructor, but from the Load event handler everything worked as planned.

Frans Bouma | Lead developer LLBLGen Pro
Jax
User
Posts: 8
Joined: 16-May-2005
# Posted on: 22-Sep-2005 22:53:44   

I'm fairly sure that the binding works fine from the Load event yes - but I've not seen any articles anywhere that explain why things don't bind properly before the load event.

The Janus control people have offered some insight into what causes the problem...

They say:

_The BindingContext is created when the Form loads, try creating the BindingContext of the UIComboBox in code before setting the DataSource

cboStaus.BindingContext = new BindingContext()_

Thanks for your help Otis. Neil

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 23-Sep-2005 11:25:00   

Jax wrote:

I'm fairly sure that the binding works fine from the Load event yes - but I've not seen any articles anywhere that explain why things don't bind properly before the load event.

The Janus control people have offered some insight into what causes the problem...

They say:

_The BindingContext is created when the Form loads, try creating the BindingContext of the UIComboBox in code before setting the DataSource

cboStaus.BindingContext = new BindingContext()_

Thanks for your help Otis. Neil

I think that explains it simple_smile I ran into a related issue the other day when I tried to set the actual row in the fields grid in the desiger in the form's constructor. That didn't work because of the same reason: the binding context wasn't created. Moving the code to the load handler worked. simple_smile

Frans Bouma | Lead developer LLBLGen Pro