We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Multi-column combo box in a gdbg

Is there a way to use a combobox cell type in a databound grid only have multiple columns show up when the dropdown button is pressed. I know about DropDownGrid cell types, but that doesn't seem to allow the auto-complete feature that a combobox in a cell grid allows. Ideally, I want the user to be able to type a value into a cell (say the code number) and have it auto-complete or drop down the list in the cell and see the codes listed with the definitions and then select a row. When selected, the selected code would then appear in the cell. If I could just add a column to the combobox list, that would be perfect. Any ideas? Thanks.

9 Replies

RA Rajagopal Syncfusion Team April 26, 2007 12:00 AM UTC

Hi Dan,

You cannot have multiple columns in the dropdown with the default combobox celltype, you can use the GridListControl celltype for this functionality. This also provides the auto complete feature that you are looking for. The datasource for the dropdown has to be set along with the DisplayMember and ValueMember properties. Please refer to the attached sample for more details.

Here is a sample http://www.syncfusion.com/Support/user/uploads/GDBG_DropDown_10348266.zip

Also refer to the ComboboxCells sample in the browser samples ( \\Celltypes\ComboboxCells )

Regards,
Rajagopal


DG Dan Garvin April 26, 2007 11:48 AM UTC

Thanks. That looks good. Wondering if the drop down grid can support sorting by clicking on the header? Thanks.

>Hi Dan,

You cannot have multiple columns in the dropdown with the default combobox celltype, you can use the GridListControl celltype for this functionality. This also provides the auto complete feature that you are looking for. The datasource for the dropdown has to be set along with the DisplayMember and ValueMember properties. Please refer to the attached sample for more details.

Here is a sample http://www.syncfusion.com/Support/user/uploads/GDBG_DropDown_10348266.zip

Also refer to the ComboboxCells sample in the browser samples ( \\Celltypes\ComboboxCells )

Regards,
Rajagopal


DG Dan Garvin April 26, 2007 01:01 PM UTC

And one more thing: How can I control the number of rows visible after dropping down the grid?
Thanks again.

>Thanks. That looks good. Wondering if the drop down grid can support sorting by clicking on the header? Thanks.

>Hi Dan,

You cannot have multiple columns in the dropdown with the default combobox celltype, you can use the GridListControl celltype for this functionality. This also provides the auto complete feature that you are looking for. The datasource for the dropdown has to be set along with the DisplayMember and ValueMember properties. Please refer to the attached sample for more details.

Here is a sample http://www.syncfusion.com/Support/user/uploads/GDBG_DropDown_10348266.zip

Also refer to the ComboboxCells sample in the browser samples ( \\Celltypes\ComboboxCells )

Regards,
Rajagopal


HA haneefm Syncfusion Team April 26, 2007 03:01 PM UTC

Hi Dan,

You can access GridDropDownGridListControlCellRenderer of the GridListControl cell and control the height of a dropdown gridlistcontrol through a DropDownRows property in the embedded GridDropDownGridListControlPart. With it, you specify the number of rows that you want to see. Here is a code snippet to show this.

private void gridDataBoundGrid1_CurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs e)
{
GridDropDownGridListControlCellRenderer cr = this.gridDataBoundGrid1.CurrentCell.Renderer as GridDropDownGridListControlCellRenderer ;
if( cr != null)
(( GridDropDownGridListControlPart) cr.ListControlPart).DropDownRows = 10;
}

Best Regards,
Haneef


DG Dan Garvin April 26, 2007 04:33 PM UTC

Great. Thanks. However, after the app opens, the first time I press the dropdown button on a grid cell, the dropdown grid is still the default size. Once I press it again, it is the new height. I moved the code up to the form load event with the same results. Any ideas? Thanks again.
-dan

>Hi Dan,

You can access GridDropDownGridListControlCellRenderer of the GridListControl cell and control the height of a dropdown gridlistcontrol through a DropDownRows property in the embedded GridDropDownGridListControlPart. With it, you specify the number of rows that you want to see. Here is a code snippet to show this.

private void gridDataBoundGrid1_CurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs e)
{
GridDropDownGridListControlCellRenderer cr = this.gridDataBoundGrid1.CurrentCell.Renderer as GridDropDownGridListControlCellRenderer ;
if( cr != null)
(( GridDropDownGridListControlPart) cr.ListControlPart).DropDownRows = 10;
}

Best Regards,
Haneef


DG Dan Garvin April 26, 2007 06:27 PM UTC

The only two problems I'm still having are 1) the dropdownrows isn't set until the second time I press the dropdown button, and 2) Can't seem to control the column widths of the dropdownlist. I'm using a griddropdownlist for two cells in a table. When I click on the first cell, the col widths look good. However, when I drop the second cell, the col widths look like they are still set to the previous cell's dropdownlist. Here is the code that sets the two cells properties:

//ICD10
gbc = binder.InternalColumns["ICD10"];
gbc.StyleInfo.CellType = "GridListControl";
DataTable dtICD10 = AVCBaseUtils.GetRecordsBySP("dbo.GetCommonDxListICD10");
dtICD10.DefaultView.Sort = "ICD10";
gbc.StyleInfo.DataSource = dtICD10;
gbc.StyleInfo.ValueMember = "ICD10";
gbc.StyleInfo.DisplayMember = "ICD10";
GridDropDownGridListControlCellRenderer gcr = (GridDropDownGridListControlCellRenderer)gridDx.CellRenderers["GridListControl"];
gcr.ListControlPart.ShowColumnHeader = false; // to hide the header in the dropdown
gcr.ListControlPart.ThemesEnabled = true;
gridDx.Model.ColWidths["ICD10"] = 60;

//Common Phrase - Grid dropdown
gbc = binder.InternalColumns["Common Phrase"];
gbc.StyleInfo.CellType = "GridListControl";
DataTable dtCommonPhrase = AVCBaseUtils.GetRecordsBySP("dbo.GetCommonDxList");
dtCommonPhrase.DefaultView.Sort = "Common Phrase";
gbc.StyleInfo.DataSource = dtCommonPhrase;
gbc.StyleInfo.ValueMember = "Common Phrase";
gbc.StyleInfo.DisplayMember = "Common Phrase";
GridDropDownGridListControlCellRenderer gcr1 = (GridDropDownGridListControlCellRenderer)gridDx.CellRenderers["GridListControl"];
gcr1.ListControlPart.ShowColumnHeader = false; // to hide the header in the dropdown
gcr1.ListControlPart.ThemesEnabled = true;
gbc.StyleInfo.DropDownStyle = GridDropDownStyle.Exclusive;
gbc.StyleInfo.DropDownStyle = GridDropDownStyle.AutoComplete;
gridDx.Model.ColWidths["Common Phrase"] = 250;


DG Dan Garvin April 26, 2007 06:31 PM UTC

I should add that the datasources of the two cells return similar results, but the column orders are different. The first cell returns a short then a long column while the second column returns just the opposite (a long then a short column). By the time I drop the second column, the columns in the dropdownlist end up being too wide in both columns. What I want is for the column widths to remain short and long in the first cell and long and short in the second cell. Hope I've explained this well enough. Thanks again.


RA Rajagopal Syncfusion Team April 26, 2007 06:50 PM UTC

Hi Dan,

Instead of handling the CurrentCellShowingDropDown, please try handling the CurrentCellActivated event. Below is the code.

void gridDataBoundGrid1_CurrentCellActivated(object sender, EventArgs e)
{
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
if (cc.Renderer.StyleInfo.CellType == "GridListControl")
{
GridDropDownGridListControlCellRenderer cr = cc.Renderer as GridDropDownGridListControlCellRenderer;
if (cr != null)
((GridDropDownGridListControlPart)cr.ListControlPart).DropDownRows = 2;
}
}



Regards,
Rajagopal



DG Dan Garvin April 26, 2007 08:49 PM UTC

Thanks. That solved the problem with the drowdownrows not working the first time. Any ideas on the col widths issue explained above? Thanks.
-dan

Loader.
Live Chat Icon For mobile
Up arrow icon