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.
Unfortunately, activation email could not send to your email. Please try again.

Format cell with percent signal

Thread ID:

Created:

Updated:

Platform:

Replies:

25163 Feb 20,2005 11:31 PM Feb 22,2005 09:24 AM Windows Forms 7
loading
Tags: GridControl
Hoang Dinh
Asked On February 20, 2005 11:31 PM

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

Hoang Dinh
Replied On February 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%" Thanks

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

Hoang Dinh
Replied On February 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.

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

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

Hoang Dinh
Replied On February 22, 2005 07:29 AM

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

CONFIRMATION

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.

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.

;