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
UltraGrid - Combo type field, is there a way of adding an expression to determine which of two display texts to show


I have a combo and it can show two different display texts for the same value. I have inserted code below to show this in a grid.

In the combo field there are two options for each "Not Viewable" entity. There is also another filed that actually shows what I would hope to be selected in the combo. If you look at the last two rows you can see Ian is showing not viewable for both the row where he is viewable and the one where he isn't as per the description field. Also, just to say that the Not Viewable text would not normally include the name, it is just there for demo.

Can you have a formula in the Entity ID firled or the combo attached that states if the description matches the the item in the combo then show that?

I hope that makes sense.



 public partial class Form1 : Form
        DataTable gridTable;
        DataTable comboTable;
        public Form1()
            ultraGrid1.Error += UltraGrid1_Error;

        private void UltraGrid1_Error(object sender, Infragistics.Win.UltraWinGrid.ErrorEventArgs e)
            var x = e.ErrorText;
            e.Cancel = true;
            this.ultraGrid1.ActiveCell.Value = 4;

        private void CreateTableAndBindToGrid()
            gridTable = new DataTable();
            gridTable.Columns.Add("EntityID", typeof(int));
            gridTable.Columns.Add("Description", typeof(String));
            this.gridTable.Rows.Add(new object[] { 1, "Paul" });
            this.gridTable.Rows.Add(new object[] { 2, "John" });
            this.gridTable.Rows.Add(new object[] { 3, "Heidi" });
            this.gridTable.Rows.Add(new object[] { 4, "Ian" });
            this.gridTable.Rows.Add(new object[] { 4, "[Not Viewable - Ian]" });
            this.ultraGrid1.SetDataBinding(this.gridTable, "", true);

        private void SetEntityIDToUltraCombo()
            this.ultraGrid1.DisplayLayout.Bands[0].Columns["EntityID"].EditorComponent = GetUltraComboEditor();
            this.ultraGrid1.DisplayLayout.Bands[0].Columns["EntityID"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownValidate;

        private void AddNewITem()
            comboTable.Rows.Add(new object[] { 4, "Ian" });

        private UltraComboEditor GetUltraComboEditor()
            comboTable = new DataTable();
            comboTable.Columns.Add("ID", typeof(int));
            comboTable.Columns.Add("EntityName", typeof(String));
            comboTable.Rows.Add(new object[] { 1, "[Not Viewable - Paul]" });
            comboTable.Rows.Add(new object[] { 1, "Paul" });
            comboTable.Rows.Add(new object[] { 2, "John" });
            comboTable.Rows.Add(new object[] { 3, "Heidi" });
            comboTable.Rows.Add(new object[] { 4, "[Not Viewable - Ian]" });
            comboTable.Rows.Add(new object[] { 4, "Ian" });

            UltraComboEditor editor = new UltraComboEditor();
            editor.BindingContext = this.BindingContext;
            editor.DataSource = comboTable;
            editor.ValueMember = "ID";
            editor.DisplayMember = "EntityName";
            editor.DropDownStyle = Infragistics.Win.DropDownStyle.DropDown;
            editor.LimitToList = true;            
            return editor;