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
1660
Ultra Win Grid Row cell formating
posted

We are using ultrawinGrid.WinGrid in my windows form and we are not able to set format for a particular rows’s cell value. Please find the below scenario :

Value 1

Value 2

row 1

10,000.00

10,000.00

row 2

16,849.00

89,236.00

row 3

21,235.00

87,329.00

row 4

88%

74%

row 5

14,234.00

25,547.00

In the above table all the rows will be in decimal format but we need display 4th row in percentage format.

Kindly provide soultion for this.

Parents
  • 1980
    Offline posted
    Hello Thangachan,

    You should apply an editor to the cells you want to format. The Editor is the object that handles the value in the cell and its value has to be of a type that the cell's editor can handle. For example, if you want to format the cells of the third row as percentage, you should do something like this:

    private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
            {
                if (e.Row.Index == 3)
                {
                    var editorSettings = new DefaultEditorOwnerSettings();
                    editorSettings.DataType = typeof(Decimal);
                    editorSettings.Format = "0'%";
                    var editor = new EditorWithText(new DefaultEditorOwner(editorSettings));
                    e.Row.Cells["Value 1"].Editor = editor;
                    e.Row.Cells["Value 2"].Editor = editor;

                }
            }


    Please note that formatting only applies to a cell that is NOT in edit mode. If the cell is editable by the user and you need different masks based on the row, then you would have to use an editor - like an UltraMaskEditor or UltraNumericEditor control and set the Editor/EditorComponent on the cell.

Reply Children