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

GridDataBoundGrid: Different DropDown-Lists in one Column

Thread ID:





3465 Mar 21,2003 09:41 AM UTC Mar 22,2003 01:17 PM UTC WinForms 5
Tags: GridControl
Asked On March 21, 2003 09:41 AM UTC

Hello, I need to provide different DropDown-Lists for the cells in one Column of a GridDataBoundGrid. Example: If in a row the value of column 1 is "Fruit" the DropDown-List of Column 2 should contain "Aple/Banana/Strawberry" If in another row the value of column 1 is "Beverage" the DropDown-List of Column 2 should contain "Coke/Pepsi/Sevenup" Is this possible with Essential Grid?

Administrator [Syncfusion]
Replied On March 21, 2003 03:19 PM UTC

Hi, I also came across the same problem. I am using a databound grid. I got this to work by adding a handler to dataGird.Model.QueryCellInfo event. In the event handler: if (e.RowIndex == 1) { e.Style.CellType = "ComboBox"; e.Style.DataSource = drinkTypesArrayList; e.Style.DisplayMember = "DrinkName"; e.Style.DisplayValue = "DrinkId"; } else if (e.RowIndex == 2) { e.Style.CellType = "ComboBox"; e.Style.DataSource = fruitTypesArrayList; e.Style.DisplayMember = "FruitName"; e.Style.DisplayValue = "FruitId"; } It is working fine. But, if I sort the data my row numbers are getting out of wack. I tried to fix this by getting row number from Binder: int rowNumber = dataGrid.Binder.RowIndexToPosition(e.RowIndex); For some reason it is not giving me the original row number in my DataTable (my datasource for the grid). It is always giving me the 0, 1, 2, 3 for row 1, 2, 3 irrespective of whether my data is sorted or not. So I added another "Index" column to my datatable and set them sequentially starting from zero. In my QueryCellInfo handler when I tried: int myOrigRowIndex = (int) dataGrid.Model[e.RowIndex, 3].CellValue; It is giving me an exception: Recursive call detected. When accessing grid cell objects from a QueryCellInfo event handler make sure you do not recursively access the same call. How do I fix this. thanks, - Reddy

Replied On March 21, 2003 05:56 PM UTC

Hi Reddy, here some sugestions against your "Recursive call" Exception: 1. Try using an boolean-flag to detect whether the event is an result of an recursive call or not: private bool inService = false; private void dataGrid_Model_QueryCellInfo_Event(object sender, GridQueryCellInfoEventArgs e) { if (!inService) { inService = true; // your Code... int myOrigRowIndex = (int) dataGrid.Model[e.RowIndex, 3].CellValue; inService = false; } } 2. Try unsubscriping the dataGird.Model.QueryCellInfo event before doing the recursive call. After that you can subscripe to the event again: private void dataGrid_Model_QueryCellInfo_Event(object sender, GridQueryCellInfoEventArgs e) { // unsubscripe dataGird.Model.QueryCellInfo -= new GridQueryCellInfoEventHandler(dataGrid_Model_QueryCellInfo_Event) // your Code... int myOrigRowIndex = (int) dataGrid.Model // subscripe dataGird.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(dataGrid_Model_QueryCellInfo_Event) } I don't know if any of this works (I didn't test it) but the idea behind both examples is that you have to avoid the continuous fireing of the QueryCellInfo-Event. hope this helps Tom

Administrator [Syncfusion]
Replied On March 21, 2003 07:30 PM UTC

Thank you very much. Your inService technique worked. thanks, - Reddy

Administrator [Syncfusion]
Replied On March 21, 2003 09:23 PM UTC

Great to see you helped out each other. Tom, did you get your original problem also working? Let us know if not. QueryCellInfo and PrepareViewStyleInfo events should let you do that. Stefan

Replied On March 22, 2003 01:17 PM UTC

Hi Stefan, my Problem is also solved. Thanks to Reddy.


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