Grid Cell generate Garbage Number if decimal set to 6 above and number < 1.
Hi,
Not sure any one meet the following problem:
1. use syncfusion DataBoundGrid
2. set a column and cell as double value type, with CurrencyEdit allow 8 decimal places, init with 0.0000000
3. run above Grid, enter 0.0000002
4. move away the cursor from that cell, you will see the number becomes 0.000000. then come back , you will see some Garbage Number 708.000000 .
Any idea ?
David
Not sure any one meet the following problem:
1. use syncfusion DataBoundGrid
2. set a column and cell as double value type, with CurrencyEdit allow 8 decimal places, init with 0.0000000
3. run above Grid, enter 0.0000002
4. move away the cursor from that cell, you will see the number becomes 0.000000. then come back , you will see some Garbage Number 708.000000 .
Any idea ?
David
SIGN IN To post a reply.
3 Replies
HA
haneefm
Syncfusion Team
October 19, 2007 12:11 AM UTC
Hi YC,
I am not sure of what be might be causing this strange behavior without a working sample. I have tested this issue in browser sample with Essentail studio V.4.x/5.x. But i was not able to reproduce the issue. Is it possible for you to upload us a minimal sample or modify the browser sample to reproduce the issue here? This will help us to analyse the issue further.
Best regards,
Haneef
I am not sure of what be might be causing this strange behavior without a working sample. I have tested this issue in browser sample with Essentail studio V.4.x/5.x. But i was not able to reproduce the issue. Is it possible for you to upload us a minimal sample or modify the browser sample to reproduce the issue here? This will help us to analyse the issue further.
Best regards,
Haneef
DA
David
October 19, 2007 01:02 PM UTC
hi, Haneef,
please see the attached example. reproducing steps still the same.
thanks a lot!
David
DoubleTextBoxBug.zip
HA
haneefm
Syncfusion Team
October 19, 2007 10:33 PM UTC
Hi David,
You can go for the TextBox celltype and the cellvaluetype as double for your needs. You can restrict the non-numeric entries to the cell handling the CurrentCellKeyPress event. To get the desired format for the cells, set the Style.Format in the PrepareViewStyle event handler. Please try the below code snippets
void gridDataBoundGrid1_CurrentCellKeyPress(object sender, KeyPressEventArgs e)
{
GridDataBoundGrid grid = sender as GridDataBoundGrid;
GridCurrentCell cc = grid.CurrentCell;
if (cc != null)
{
if (e.KeyChar == '.')
{
string sCellText = cc.Renderer.ControlText;
if (sCellText.IndexOf(".") != -1)
{
e.Handled = true;
}
}
else if (!char.IsNumber(e.KeyChar))
e.Handled = true;
else
{
GridTextBoxCellRenderer cr = cc.Renderer as GridTextBoxCellRenderer;
cr.TextBox.SelectionLength = 1;
}
}
}
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex > 0 && e.Style.CellValue != null && e.Style.CellValue.ToString().Trim() != string.Empty)
{
e.Style.CellValueType = typeof(double);
e.Style.HorizontalAlignment = GridHorizontalAlignment.Right;
e.Style.Format = "F8";
}
}
Best regards,
Haneef
You can go for the TextBox celltype and the cellvaluetype as double for your needs. You can restrict the non-numeric entries to the cell handling the CurrentCellKeyPress event. To get the desired format for the cells, set the Style.Format in the PrepareViewStyle event handler. Please try the below code snippets
void gridDataBoundGrid1_CurrentCellKeyPress(object sender, KeyPressEventArgs e)
{
GridDataBoundGrid grid = sender as GridDataBoundGrid;
GridCurrentCell cc = grid.CurrentCell;
if (cc != null)
{
if (e.KeyChar == '.')
{
string sCellText = cc.Renderer.ControlText;
if (sCellText.IndexOf(".") != -1)
{
e.Handled = true;
}
}
else if (!char.IsNumber(e.KeyChar))
e.Handled = true;
else
{
GridTextBoxCellRenderer cr = cc.Renderer as GridTextBoxCellRenderer;
cr.TextBox.SelectionLength = 1;
}
}
}
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex > 0 && e.Style.CellValue != null && e.Style.CellValue.ToString().Trim() != string.Empty)
{
e.Style.CellValueType = typeof(double);
e.Style.HorizontalAlignment = GridHorizontalAlignment.Right;
e.Style.Format = "F8";
}
}
Best regards,
Haneef
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
DA David
- Oct 18, 2007 04:19 PM UTC
- Oct 19, 2007 10:33 PM UTC