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
600
Different cell-format in same column
posted

Hi,

I've a wingrid with a column, type numeric. In InitializeLayout-event I write 'NumCol.Format = "N0"'. But in some rows of this column I need 'Format="N2"'. Is this possible ?

I'm using Infragistics 7.3

Thanks

Hansjörg Wintermantel

Parents
No Data
Reply
  • 69832
    Verified Answer
    Offline posted

    The following code sample demonstrates how to use an EmbeddableEditorOwnerBase-derived class which overrides the GetFormatInfo method to format cells differently in every other row:

    DefaultEditorOwnerSettings settings = new DefaultEditorOwnerSettings();
    MyDefaultEditorOwner owner = new MyDefaultEditorOwner();
    this.ultraGrid1.DisplayLayout.Bands[0].Columns["whatever"].Editor = new EditorWithText( owner );

    public class MyDefaultEditorOwner : DefaultEditorOwner
    {
        public override void GetFormatInfo(object ownerContext, out string format, out IFormatProvider provider)
        {
            provider = null;

            CellUIElement cellElement = ownerContext as CellUIElement;
            UltraGridColumn column = cellElement.Column;
            UltraGridRow row = cellElement.Row;

            if ( (row.Index % 2) == 0 )
                format = "N0";
            else
                format = "N2";
        }
    }

Children