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
95
How Remove Scientific Notation
posted

I use WinGrid table. Standard behavior when numbers are less than 10-4 is to convert it to scientific notation. I can prevent it by assigning format to the column, but when content of cell is selected it is still converts to scientific notation. When cell lose focus it converts back to non scientific notation. How can prevent scientific notation when cell is selected.

Thank you.

Parents
No Data
Reply
  • 1590
    posted

    Hi. 

    I have faced the same problem. My solution is the following:

    In AfterEnterEditMode event of UltraGrid I made the next check

    ......

                UltraGridCell cell = grid_.ActiveCell;
                if (cell != null && cell.IsDataCell)
                {

                   // The column with "Value" key  contains double numbers.

                   if (cell.Column.Key == "Value")
                    {
                        EditorWithText editor = cell.EditorResolved as EditorWithText;
                        if (editor != null && editor.TextBox != null)
                        {
                            string formattedNumber = cell.Value.ToString();
                           
                            if (formattedNumber.IndexOf("E") != -1)

                                {
                                    formattedNumber = String.Format("{0:0.#######################}", element.Cell.Value);                                           
                                    editor.TextBox.Text = formattedNumber;
                                    editor.TextBox.SelectAll();

                               }
                        }
                    }
                }

     Alex. 

Children
No Data