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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

grid drop down

Thread ID:

Created:

Updated:

Platform:

Replies:

45028 Jun 8,2006 04:40 PM UTC Jun 23,2006 07:29 PM UTC WinForms 2
loading
Tags: GridControl
Curtis Gulick
Asked On June 8, 2006 04:40 PM UTC

I have a question regarding databinding dropdowns in a grid vs the cells that are prepopulated above the entry dropdown. I have a grid that contains say 10 rows of colors. The last record is the editable row which contains a drop down of the available colors to pick from. I also have a dropdown outside the grid below that lets you filter out what rows are listed above to view. The drop down in the grid and outside the grid have different data adapters to handle this. This is done so that the user can enter new rows with a restricted amount of colors, but they can view all colors that have ever been entered. What is happening is the dropdown in the grid has 5 colors, the drop down outside determining what should be displayed in the grid has 10 ... however the other 5 never display because the values are not bound to the cells since that binding happens from the dropdown in the grid. The dropdown within the grid and the cells for the rows above it seem to pull from the same datasource. I would like to separate that so that the cells above can map to the datasource from my dropdown outside of the grid. Does anyone know if this is possible and how to do it? Thanks, Curtis

Administrator [Syncfusion]
Replied On June 9, 2006 05:47 AM UTC

Hi Curtis , Could you try this code to add the item(colors) in a dropdown of the grid using the grid''s CurrentCellShowingDropDown event. Here is a code snippet, private void gridDataBoundGrid1_CurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs e) { GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer; if(cr != null ) { cc.BeginEdit(true); // DropDown inside Grid DataTable GridDropDown = cr.ListBoxPart.DataSource as DataTable; //Outside DropDown DataTable DataTable ComboTable = this.comboBox1.DataSource as DataTable; //change the DataSource Depends upon the outside DropDown" if(ComboTable != null) { for(int i = 0 ;i < ComboTable.Rows.Count;i++) { DataRow crow = ComboTable.Rows[i]; bool isExist = false; for(int j = 0 ;j < GridDropDown.Rows.Count;j++) { //ColorItem is the DisplayMember of the combo and GridcomboBox. if(crow["ColorItem"] == GridDropDown.Rows[0]["ColorItem"] ) { isExist = true; break; } } if(!isExist) { DataRow dr1 = GridDropDown.NewRow(); dr1[1] = crow["ColorItem"]; GridDropDown.Rows.Add(dr1); } } } cr.ListBoxPart.DataSource = GridDropDown; cc.EndEdit(); } } Let me know if this helps. Best Regards, Haneef

Curtis Gulick
Replied On June 23, 2006 07:29 PM UTC

Haneef, this worked! Thanks! >Hi Curtis , > >Could you try this code to add the item(colors) in a dropdown of the grid using the grid''s CurrentCellShowingDropDown event. Here is a code snippet, > >private void gridDataBoundGrid1_CurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs e) >{ > GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; > GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer; > > if(cr != null ) > { > cc.BeginEdit(true); > > // DropDown inside Grid > DataTable GridDropDown = cr.ListBoxPart.DataSource as DataTable; > > //Outside DropDown DataTable > DataTable ComboTable = this.comboBox1.DataSource as DataTable; > > //change the DataSource Depends upon the outside DropDown" > if(ComboTable != null) > { > for(int i = 0 ;i < ComboTable.Rows.Count;i++) > { > DataRow crow = ComboTable.Rows[i]; > bool isExist = false; > for(int j = 0 ;j < GridDropDown.Rows.Count;j++) > { > //ColorItem is the DisplayMember of the combo and GridcomboBox. > if(crow["ColorItem"] == GridDropDown.Rows[0]["ColorItem"] ) > { > isExist = true; > break; > } > } > if(!isExist) > { > DataRow dr1 = GridDropDown.NewRow(); > dr1[1] = crow["ColorItem"]; > GridDropDown.Rows.Add(dr1); > } > } > } > cr.ListBoxPart.DataSource = GridDropDown; > cc.EndEdit(); > } >} > >Let me know if this helps. >Best Regards, >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.

Warning Icon 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.Close Icon

;