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.
Unfortunately, activation email could not send to your email. Please try again.

GridGroupingControl - ComboBox with different number of items per record

Thread ID:

Created:

Updated:

Platform:

Replies:

46079 Jul 5,2006 11:56 AM Jul 6,2006 05:46 AM Windows Forms 4
loading
Tags: GridControl
Clive Hill
Asked On July 5, 2006 11:56 AM

Hi, I want to display a ComboBox in one of the cells of a GridGroupingControl that is populated dynamically. When information for a new row is received, I get a reference to the grids DataSource, which is a DataTable. From that I do newRow, and populate the cells. For the ComboBox cell, I populate a StringCollection with wanted values. If I directly assign this to the cell like: newRow["ComboBox"] = comboBoxValues; The string "System.Collections.Specialized.StringCollection" is displayed. I would like to get a reference to a cell and set CellType = "ComboBox" and ChoiceList to comboBoxValues. I could add the row first and then get reference to row by specifying value of a primary key cell, but I can only see how to do this by using the row index + col index. Can someone give me pointers on the best way to dynamically populate a ComboBox in a cell of a GridGroupingControl?

Administrator [Syncfusion]
Replied On July 5, 2006 12:35 PM

Hi Vito, Try this code in TableControlCurrentCellShowingDropDown to dynamically build the datasource of the ComboBox cell in a grid. Here is a code snippet. GridCurrentCell cc = e.TableControl.CurrentCell; GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer; if( cr != null) { object obj = e.TableControl.Table.CurrentRecord.GetValue("parentID"); if(obj is int) { StringCollection ComboList = new StringCollection(); ComboList.Add(obj.ToString() ); ComboList.Add("Modified"); cr.ListBoxPart.DataSource = ComboList; } } Here is a sample. http://www.syncfusion.com/Support/user/uploads/comboBoxDynamic_ae6d5ba6.zip Let me know if this helps. Best Regards, Haneef

Clive Hill
Replied On July 5, 2006 01:20 PM

I noticed that this sample is blank until clicking on the down arrow, despite being pre-populated "One" to "Five". How can I assign an initial value without waiting for TableControlCurrentCellShowingDropDown event? Its a shame that this model requires the user to perform a click to then build up the drop down list. In my example, data is coming from externally into the system to build up the record. It would have been good to build up the ComboBox at the same time as populating the rest of the row. Seems like now I will have to cache the data, and retrieve it when the user clicks on the ComboBox. Is there a way to populate the ComboBox at the same time as doing the other cells in the DataRow, and pre-select one of the items in the ComboBox (giving initial text)?

Administrator [Syncfusion]
Replied On July 5, 2006 03:46 PM

Hi Vito, To load the datasource of the combobox cell intailly in a grid, you need to handle the QueryCellStyleInfo event. Here is a code snippet. private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if( e.TableCellIdentity.Column != null && e.TableCellIdentity.Column.MappingName == "ComboList" && e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record ) { Record rec = e.TableCellIdentity.DisplayElement.ParentRecord; if( rec != null) { object obj = rec.GetValue("parentID"); if(obj is int) { StringCollection ComboList = new StringCollection(); ComboList.Add(obj.ToString() ); ComboList.Add("Modified"); e.Style.CellType = "ComboBox"; //Pre select the item from the dropdown e.Style.Text = ComboList[0]; e.Style.ChoiceList = ComboList; } } } } Let me know if this helps. Best Regards, Haneef

Clive Hill
Replied On July 6, 2006 05:46 AM

If I cache the event information I can use this method to populate the ComboBox. Thanks Haneef

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;