Please note: In an effort to better serve you, we are in the process of restructuring DevCenter. In the process, we have moved many items that you may be used to finding in DevCenter over to the Main Site. If you are having trouble locating something, please try looking at the following places:
Prior to the release of the WinGrid v3 in NetAdvantage 2003 Volume 3, the value list and editor control references were only on the UlraGridColumn object. With the release of the WinGrid v3 these properties were moved down to the UltraGridCell level. With this change, the process to display different UltraCombos on a cell-by-cell basis in a column became more simplified.
When the WinGrid is drawing to screen, columns that have an UltraCombo type editor use the UltraCombo’s DisplayMember to display the proper text in the cell. If the value of the cell is not found in the UltraCombo, the UltraWinGrid should show the value of the cell in an unformatted way. For example, in the case of an UltraCombo populated with the names of states, if the value “NY” is not found, then the cell will show “NY”. However this can become problematic if the ColumnType is a DropDownList, as this value is clearly not in the value list. Due to this behavior, simply switching the DataSource of the UltraCombo will cause the other rows in the column that share the UltraCombo as an editor to flicker display between showing the value of the column, when the value is not found in the current UltraCombo, or the desired DisplayMember text, when the value can be paired up. The correct way to use a dynamic UltraCombo as a cell editor is to use two UltraCombo controls: one UltraCombo to act as a global source and a second to act as a cell editor.
To accomplish the goal of having the UltraCombo vary based on the value of another cell, set an UltraCombo to be the editor on the UltraGridColumn object. This UltraCombo should contain all the possible value member and display member pairs.In C#:
In VB.NET:
Since this UltraCombo will be used as the editor for all cells in the column that don’t have an editor explicitly tied to the cell, this will allow the cells to always show the correct display text in the cell as opposed to the value of the cell.In the BeforeEnterEditMode of the cell that will have the dynamic UltraCombo, switch the datasource on the UltraCombo to be the DataSource for that particular cell. Then set the editor on the cell to be the second, more specific UltraCombo.In C#:
Finally, in the BeforeCellDeactivate, set the ValueList of the cell to Nothing (or null in C#). This will allow the cell to use the column's ValueList as its source.In C#: