I want to show a drop down-list for cells of a specific column. Furthermore the drop down values should be filtered depending on another cell value. In order to achieve this behavior I derieved from EditorWithCombo and I overwrote the ValueList-Property:
public class ValueListEditor : EditorWithCombo{ private ValueList _ValueList = null;
public ValueListEditor(ValueList valueList) : base() { _ValueList = valueList; }
public override IValueList ValueList { get { return m_oValueList; } }}
In order to display the text instead of the value I overwrote the GetElementText() method.
protected override string GetElementText(EmbeddableUIElementBase element, bool ignorePasswordChar){ if (element != null && element.OwnerContext is CellUIElement && ((CellUIElement)element.OwnerContext).Cell != null) { UltraGridCell cell = (element.OwnerContext as CellUIElement).Cell; object value = cell.Value;
if (cell.EditorResolved != null && cell.EditorResolved.IsInEditMode && cell.EditorResolved.IsValid) value = cell.EditorResolved.Value;
int index = -1; string text = string.Empty;
text = this.ValueList.GetText(cell.Value, ref index); return text; }
return base.GetElementText(element, ignorePasswordChar);}
In some cases the text which is displayed by the cell differs from the text, when you enter the edit mode of the cell. I have to mention that I assign a new value to the cell, when another cell value has changed. Any suggestions?
Hi,
I'm glad you got it working. :)
But did you know that the UltraCombo and UltraDropDown controls already have RowFiltering functionality built-in, just like the WinGrid does? That might be easier.
ok I solved the problem. I will post the answer for everyone who has the same problem. To derive from the EditorWithCombo class isn't necessary. Here is the code in order to create an instance of EditorWithCombo with a specific value list:
DefaultEditorOwnerSettings settings = new DefaultEditorOwnerSettings();settings.ValueList = _valueList[key];ultraGrid1.ActiveRow.Cells["myColumn"].Editor = new EditorWithCombo(new DefaultEditorOwner(settings));