We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Format cell with percent signal

Thread ID:





25163 Feb 21,2005 04:31 AM UTC Feb 22,2005 02:24 PM UTC WinForms 7
Tags: GridControl
Hoang Dinh
Asked On February 21, 2005 04:31 AM UTC

Hi, I have an issue when display a double value into gird with percent signal, For Example: 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, Hoang

Administrator [Syncfusion]
Replied On February 21, 2005 09:17 AM UTC

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.

Hoang Dinh
Replied On February 21, 2005 10:16 AM UTC

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%" Thanks

Administrator [Syncfusion]
Replied On February 21, 2005 11:05 AM UTC

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%. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=17345

Hoang Dinh
Replied On February 22, 2005 02:35 AM UTC

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.

Administrator [Syncfusion]
Replied On February 22, 2005 09:51 AM UTC

What are you doing in SaveCellFormattedText? You should change the 7.0% into .07 in that event.

Hoang Dinh
Replied On February 22, 2005 12:29 PM UTC

Thanks, 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,

Administrator [Syncfusion]
Replied On February 22, 2005 02:24 PM UTC

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.)


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon