Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Bound Grid with ComboBox

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Bound Grid with ComboBox
Link Posted: 06-Feb-2006 10:46
Hello,
do you have any sample how to use comboboxes in a bound grid.

I want do the following:

In the main datatable I have a field with country-codes.

I also have a country datatable.

Now I want show in the grid row "Country" a combobox which holds all the country-names coming out of country table.

If the grid is filled with the main datatable I want to show the country name in the combobox which is based on the country code.

Thanks and regards
Uwe
Link Posted: 06-Feb-2006 21:16
Use LookupListColumn for these purposes.
See the Master/Detail or Filters and Summaries samples for more details.
Link Posted: 07-Feb-2006 04:21
First thanks for the reply.

In the Masterdetail sample the data is coming from one table/dataset.

Is there also a sample available where the lookupcolumn comes from a differnt table.

What I did now is:

LookupListColumn LandLookup = new LookupListColumn(dc.Caption, dc.ColumnName);
LandLookup.EditorStyle = EditorStyle.DropDown;
LandLookup.DropDownStyle = DropDownStyle.DropDownList;
LandLookup.LookupSource = dsLand.Tables["T_LAND"];
LandLookup.LookupBoundField = "Land";
LandLookup.LookupDisplayField = "Land";
col = LandLookup;

In dc the result of the main table is stored, in dsLand I have a select for all the country names.

Result is:

In the cell the number (country key is shown) when I use the Combobox the country names are shown. But they are not linked. I want that the country name for the country key is shown in the cell. And if I change the name with the combobox I want to see the new name in the cell.



Thanks
Uwe
Link Posted: 07-Feb-2006 22:54
You've incorrectly defined these properties:

LandLookup.LookupBoundField = "Land";
LandLookup.LookupDisplayField = "Land";



for example, your table Land has two fields:
int LandId; //unique id of country
string LandName; //name of the country

and has following values:

LandId    | LandName
------------------------
1         | USA
2         | UK
3         | Canada
4         | France
5         | Germany


LookupBoundField - is a field for lookup data.  In this case this is a LandId field.
LookupDisplayField - is a field name that used to display data from lookup table. In this case this is a LandName field.


LandLookup.LookupBoundField = "LandId";
LandLookup.LookupDisplayField = "LandName";
Link Posted: 08-Feb-2006 03:35
It works. Thanks your your help.