Esempio n. 1
0
        public void UpdateDisplayText(IEntityCollection eColl,
                                      CustomColumnDisplayTextEventArgs e)
        {
            xCol xc;

            if (ListCols.TryGetValue(e.Column.AbsoluteIndex, out xc))
            {
                if (e.ListSourceRowIndex < 0)
                {
                    if (e.RowHandle == GridControl.NewItemRowHandle)
                    {
                        e.DisplayText = string.Empty;
                    }
                    else if (e.DisplayText.Length == 0)
                    {
                        e.DisplayText = e.Value.ToString();
                    }
                }
                else if (xc.fldDisplay != null)
                {
                    e.DisplayText = xc.fldDisplay.GetValue(
                        eColl.GetValue(e.ListSourceRowIndex)).ToString();
                }
                else if (xc.DisplayMember.Length > 0)
                {
                    BaseEntity be = eColl.GetValue(e.ListSourceRowIndex);
                    //xc.fldDisplay = MetaData.GetTableDef(be.GetType())
                    //    .GetFieldDef(xc.DisplayMember);
                    //if (xc.fldDisplay == null)
                    //    xc.fldDisplay = MetaData.GetTableDef(be.GetType())
                    //        .GetFieldDef(e.Column.FieldName);
                    //if (xc.fldDisplay != null)
                    //    e.DisplayText = xc.fldDisplay.GetValue(be).ToString();
                    //else
                    //{
                    object Tmp = be[xc.DisplayMember];
                    if (Tmp == null)
                    {
                        if (e.Value != null)
                        {
                            e.DisplayText = e.Value.ToString();
                        }
                    }
                    else
                    {
                        e.DisplayText = Tmp.ToString();
                    }
                    //}
                }
                else if (e.Value != null)
                {
                    e.DisplayText = e.Value.ToString();
                }
            }
        }