DataBind Janus MultiColumnCombo

Posts   
 
    
havoc1
User
Posts: 8
Joined: 06-May-2005
# Posted on: 26-Jun-2005 23:31:05   

Hi,

I am using Winforms, the Adapter model and a Janus MultiColumnCombo control.

I have a database design whereby I have a main table with a field which is a foreign key into a lookup table that has the textual description for that field. I.e. if the value is 1 the description is "car", 2 is "house", etc.

I need to create a MultiColumnCombo on a form where I can show all the values from the lookup table but show the selected value from the main table, and then save that selected value back to the main table. What do I need to put into my Databindings.Add() method call to do this?

Any help greatly appreciated, it is doing my head in!

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 27-Jun-2005 10:23:19   

Below is an example of a dropdown box (but this is similar to the janus multicombo) which is bound to an FK field in the entities of another collection which is bound to a grid. When a row in the grid is selected, the value of the FK field is reflected in the combo box.


_regionCombo.DataSource = regions;

_regionCombo.DisplayMember = "RegionDescription";
_regionCombo.ValueMember = "RegionId";

_employeeGrid.DataSource = employees;
_regionCombo.DataBindings.Add("SelectedValue", employees, "RegionId");

regions is an EntityCollection with RegionEntity instances. employees is an EntityCollection with EmployeeEntity instances. EmployeeEntity has a field called 'RegionId' which is the FK to the region entity related to that employee.

Frans Bouma | Lead developer LLBLGen Pro
havoc1
User
Posts: 8
Joined: 06-May-2005
# Posted on: 27-Jun-2005 11:22:31   

Otis wrote:

Below is an example of a dropdown box (but this is similar to the janus multicombo) which is bound to an FK field in the entities of another collection which is bound to a grid. When a row in the grid is selected, the value of the FK field is reflected in the combo box.


_regionCombo.DataSource = regions;

_regionCombo.DisplayMember = "RegionDescription";
_regionCombo.ValueMember = "RegionId";

_employeeGrid.DataSource = employees;
_regionCombo.DataBindings.Add("SelectedValue", employees, "RegionId");

regions is an EntityCollection with RegionEntity instances. employees is an EntityCollection with EmployeeEntity instances. EmployeeEntity has a field called 'RegionId' which is the FK to the region entity related to that employee.

Thanks - that works, mostly. However I can't bind to the SelectedValue property as it complains that I can't do that. If I change SelectedValue to Value then I see the relevant text in the combo box but pressing the dropdown button doesn't show the other values I could select. How can I get them?

Mark

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 27-Jun-2005 12:23:30   

You do bind the complete list of possible values as a separate collection to the multi-combo?

I know I had some problems as well with the multi-combo getting to work to select the value I needed, from code. it turned out I indeed had to set the Value property, so binding to taht should work.

Frans Bouma | Lead developer LLBLGen Pro
havoc1
User
Posts: 8
Joined: 06-May-2005
# Posted on: 27-Jun-2005 12:51:46   

Otis wrote:

You do bind the complete list of possible values as a separate collection to the multi-combo?

I know I had some problems as well with the multi-combo getting to work to select the value I needed, from code. it turned out I indeed had to set the Value property, so binding to taht should work.

Got it working, but not with the Janus controls - deleted it and used the regular Windows one and it works fine....