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. Image for the cookie policy date
close icon

Parsing and Formatting Cell Values

Hi,

I'd like to know if there is a way to format/parse a cell value of a GridDataBoundGrid?

my Grid is databounded to a BindingSource.

For example, if I had a textbox i would do so
"
this.tbxLastModifDate.DataBindings["Text"].Format += new ConvertEventHandler(tbxLastModifDate_Format);
this.tbxLastModifDate.DataBindings["Text"].Parse += new ConvertEventHandler(tbxLastModifDate_Parse);
"

But How can I make it with Syncfusion grid?

Thx

4 Replies

AD Administrator Syncfusion Team December 15, 2006 04:48 AM UTC

Hi Barzot ,

You can set StyleInfo.Format property for formatting the cell values. You can specify the numeric foramt string, Date format string or enumeration format string. Please refer to the attached browser sample for more details.

this.gridDataBoundGrid1.Binder.InternalColumns[1].StyleInfo.Format = "C05";

Sample: GDBGCellFormat.zip

Also refer our shipped TextFormat browser sample for more details.
[install path:]\Syncfusion\Essential Studio\4.3.0.25\windows\Grid.Windows\Samples\Quick Start\TextFormat\

Best Regards,
Haneef


BA Barzot December 15, 2006 08:56 AM UTC

Hi,

Thx for your answer, but in my case, it's not just that, with the value I get from the database, I have to apply a method to calculate a readable data for the user, and then parse the value from the user to the database.

In Attachment, you'll find a projet in C# 2005 with a little example of what i mean.

Thx a lot,
Barzot

SyncFusion.Grid.AppTest.zip


AD Administrator Syncfusion Team December 15, 2006 10:32 AM UTC

Hi Barzot,

This can be achieved by handling the Model.QueryCellFormattedText event and set e.Handled = true to handle it. Here is a code snippet to show this.

//For display the formatted text.
void Model_QueryCellFormattedText(object sender, Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs e)
{
if (e.Style.CellIdentity.ColIndex == 4 && e.Value != null)
{
Double result;
if (Double.TryParse(e.Value.ToString(), out result))
{
e.Text = clsDateConversion.CacheToDotNet(result).ToString();
///must set e.Handled = true to handle it
e.Handled = true;
}
}
}

Please refer to the modified sample for more details.
SyncFusion.Grid.AppTest.zip

Best Regards,
Haneef


BA Barzot December 15, 2006 01:12 PM UTC

Hi Haneef,

I just want to thank you for your help and support by Syncfusion, great work guys.

Keep Doin' such good work.

Bye

Loader.
Live Chat Icon For mobile
Up arrow icon