I have an issue when display a double value into gird with percent signal,
Value in database : "0.06".
So I need display in Gird with value "6.0%"
Please show me how to resolve this issue
Thank in advance,
ADAdministrator Syncfusion Team February 21, 2005 04:17 AM
You set the style.CellValueType = typeof(double) and style.Format = "P1".
Now, you have explicitly added GridBoundColumns using GridDataBoundGrid.GridBoundColumns.Add from code or have added them with the designer, you would use the grid.GridBoundColumns["colname"].StyleInfo to set these styles.
If you have not explicitly added GridBoundColumns, you would use the grid.Binder.InternalColumns["colname"].StyleInfo to set these styles.
HDHoang DinhFebruary 21, 2005 05:16 AM
Yes, I am using
Binder.InternalColumns[ColumnName] to set style.
But still have some isues:
1/ the begin value in a cell is "6.0%", After I deleted 6 and change current value in this cell to "7.0%" and press tab
--> Result: an error message show as "7.0% is not a valid value for Double"
2/ the begin value in a cell is "6.0%", After I deleted 6 and change current value in this cell to "7.0" and press tab
--> Result: The value of the current cell change to "700.00%"
--> How to control these issues? I need current value in that cell always is "7.0%"
ADAdministrator Syncfusion Team February 21, 2005 06:05 AM
Take a look at this forum thread. It has a sample using QueryCellFormattedText and SaveCellFormattedText to has special requirements like 7.0 being used as 7.0% instead of (excel-like) 7.0 being 700%. Using these events also should avoid the problem with your user typing 7%.
HDHoang DinhFebruary 21, 2005 09:35 PM
Thanks,I using QueryCellFormattedText and SaveCellFormattedText as your mentioned. It look good.
But at the begining of my question.
I have a value in datatable is "0.06", and I would like to show on the gird as "6.0%". After that, when I changed to new value "7.0%", I would like to save to datatable as "0.07".Because after I changed to new value "7.0%", I saw new value in datatable is "7.0". I expect this value is "0.07"
Please help me to resolve this issue.
ADAdministrator Syncfusion Team February 22, 2005 04:51 AM
What are you doing in SaveCellFormattedText? You should change the 7.0% into .07 in that event.
HDHoang DinhFebruary 22, 2005 07:29 AM
May I ask another issue?
How to set focus on a cell?
After user type a value into a cell, I must validate this cell to check whether or not the value in this cell is correct. If it is incorrect, I must set focus on this cell. User can not change to another cell except fill a correct value in this cell.
Can you help me?
Thank in advance,
ADAdministrator Syncfusion Team February 22, 2005 09:24 AM
Try handling the CurrentCellValidating event. In that event, if grid.CurrentCell.Renderer.ControlText holds an invalid value, the set e.Cancel = true. This will make it so your user cannot leave the cell. (You can also set grid.CurrentCell.ErrorMessage if you want a message to be displayed at this point.)