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.
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.
It isn't really the grid doing this. The grid just calls the ToString method of the value. So this is the behavior of DotNet.
I assume when you say "selected" you mean when the cell is in edit mode. Format only applies when the cell is not in edit mode. When it's in edit mode, the Mask properties like MaskInput are applied. So you might be able to get the behavior you want using a mask.