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
40
Custom format for Cell
posted

I would like to custom format for one cell in the grid. The grid has a column with double data type.

I formated this column: 

ugrd.DisplayLayout.Bands[0].Columns["columnName"].Format = "#,###,##0.00";

But in the cell of the first row of this column, I would like to change the format to percent.

How can I do that.

 

Parents
  • 37774
    Suggested Answer
    posted

    You could create a new EditorControl to use on any cell that you want to have a different format than the rest of the column:

    private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
    {
        if (e.Row.Index == 0)
        {
            UltraGridCell cell = e.Row.Cells[2];
            if (cell.EditorControl == null)
            {
                UltraNumericEditor editor = new UltraNumericEditor();
                editor.FormatString = "p";
                cell.EditorControl = editor;
            }
        }
    }

    Of course, if you want to do this on more than one cell, it's recommended that you only create this editor once on the form and reuse it for each cell as necessary.

    -Matt

Reply Children