Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
110
EditorWithCombo & Changing Value List
posted

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?