Stanislav
2018-09-03T10:16:07Z
Hello,

I use iGrid's dropdown control in one of iGrid columns. This column displays an enumeration (stored in cell.Value) as text associated with the dropdown control's iGDropDownListItem (so iGDropDownListItem.Value = cell.Value, iGDropDownListItem.Text = cell's display text). This works well if the dropdown list items are the same for each row. However, my dropdown list must have specific items depending on the selected grid row, so I refill the dropdown list in SelectionChanged event of the grid. Because the grid stores the selected iGDropDownListItem item in AuxValue, it cannot match this AuxValue to one of the new items (because I add different iGDropDownListItem objects to the list with the same Value and Text properties), and when I drop down the list the current cell value is not automatically selected from among the dropdown list items. I tried creating a custom class which inherits iGDropDownListItem and implementing its CompareTo method:

class GridDropDownListItem : iGDropDownListItem, IComparable<GridDropDownListItem>, IComparable
{
public int CompareTo(GridDropDownListItem other)
{
if (other == null) return 1;
return Mode.CompareTo(other.Mode);
}

public int CompareTo(object obj)
{
var item = obj as GridDropDownListItem;
if (item == null) return 1;
return CompareTo(item);
}
}
However this does not work: the grid displays enumeration text instead of iGDropDownListItem.Text and the value is not selected from dropdown list items.

Can you help?

Thank you!

Best regards,
Stanislav
Igor/10Tec
2018-09-03T16:58:19Z
It's not a correct usage of iGrid's built-in drop-down lists. If two different combobox cells should contain different sets of items, you need to use two different drop-down lists in these cells. If I understood your problem properly, using the same iGDropDownList in two cells and re-populating it on changing the current cell may lead to undesired side effects like you described.

Is it a problem for your app to create as many iGDropDownList's as you need? iGrid allows you to use different drop-down lists even in the cells of the same column.
Stanislav
2018-09-04T05:23:47Z
Hello Igor,

Thanks a lot for your prompt response. I didn't think about using a different style with different comboboxes for different cells of the same column. This is a great solution.

Yesterday I ended up creating a private array of iGDropDownListItem and just refilling the combobox with these items. This way the objects in AuxValue and the combobox are always the same. I also thought about controlling visibility of combobox items, hiding or showing relevant items in SelectionChanged event.

Best regards,
Stanislav
Stanislav
2018-09-04T09:11:22Z
Igor,

I have a quick question regarding iGDropDownList again. I have a list of files with File Name in Column 1 and Worksheet in Column 2. The worksheet must be selected from a dropdown list containing the list of worksheets of the file. Obviously, the list of worksheets of each file is going to be different. It is possible that the file list will contain dozens of files. As far as I understand, I have several options:
1) create a single dropdown list and add all unique worksheet names to this list, and then hide/show dropdown list items in SelectionChanged event based on iGDropDownListItem.Value (worksheet name),
2) create as many cell styles + dropdown lists as there are files in the grid.
The first solution seems better to me. However, both solutions look like a workaround. The code would be much cleaner if I simply refilled the list with available worksheet names in SelectionChanged. Is there a better/cleaner solution using iGDropDownList?

Thank you!
Best regards,
Stanislav
Igor/10Tec
2018-09-05T07:10:55Z
As I wrote in my post #2, you should not use the same iGDropDownList in several cells and repopulate its items with own set of items for every cell. So you definitely need to use the second approach. You can create the required iGDropDownList's and assign them to the cells in the Worksheet column on-the-fly solely in code after the user has selected a file in the File Name column.