Comma seperator
Hi ,
Currently I am binding grid with the list using UnboundValueAccessor() class.
For sorting purpose you said I need to add the value with double, if not sorting will not be corrected because of adding string.
now I change the cell value like this.
_LstFeeds[0]["price"].Value = doutput;
doutput is the double value. so the sorting is okay.
But now I want to do comma separator in this value.
If i add comma separator, the value will be string. So there will be an impact for sorting.
How can I do it?
-
Hi,
You can do it with custom formatting. Formats are objects, indicating the grid how to display values in cells. By default if a format is not specified, the grid calls Object.ToString(). But this can be changed with formats. Each format has 3 methods: Format, Parse & CanParse(). Two last methods are used in edit operations to transform text to a real value (for ex. when user tapes text in a textbox). In your case you should implement only Format() method. The best way to apply the format is Column.Format property.
Here is an example:
class CustomFormat : Dapfor.Net.Formats.IFormat
{
public string Format(IDataField dataField)
{
//your custom formatting
string formattedString = string.Format(System.Globalization.CultureInfo.InvariantCulture,
"{0}",
dataField.Value);
return formattedString.Replace(".", ",");
}
public bool CanParse(string text, IDataField dataField)
{
return false;
}
public void Parse(string text, IDataField dataField)
{
}
}
//Set the format:
grid.Headers[0]["some column"].Format = new CustomFormat();Best regards,
Dapfor0
Please sign in to leave a comment.
Comments
1 comment