using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;

namespace _1
{
    class MyCreation:IUIElementCreationFilter
    {
        private string sourceColumn;
        private string formatColumn;
        private string format;

        public MyCreation(string sourceColumn, string formatColumn, string format)
        {
            // TODO: Complete member initialization
            this.sourceColumn = sourceColumn;
            this.formatColumn = formatColumn;
            this.format = format;
        }

        #region IUIElementCreationFilter Members

        public void AfterCreateChildElements(UIElement parent)
        {
            if (parent is TextUIElement && parent.GetAncestor(typeof(DateTimeEditorUIElement)) != null)
            {
                RowUIElement row = (RowUIElement)parent.GetAncestor(typeof(RowUIElement));
                if ((bool)row.Row.Cells[sourceColumn].Value)
                    ((TextUIElement)parent).Text = ((DateTime)row.Row.Cells[formatColumn].Value).ToString(format);
            }
        }

        public bool BeforeCreateChildElements(UIElement parent)
        {
            return false;
        }

        #endregion
    }
}
