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

Custom cell formatting with IFormatProvider

Is there a way to use an IFormatProvider to dictate cell format rather than the GridStyleInfo.Format string.

Thanks,
Anthony


5 Replies

ES Eswari S Syncfusion Team August 16, 2011 09:22 AM UTC

Hi Anthony,

Thanks for using Syncfusion products.

Sorry for the inconvenience caused. Before we start providing the solution, we would like to hear the platform using by you(eg : Grid[windows] or Grid[Web]).

Could you please provide us the above details so that we could provide you a better solution? The information provided would be of great help in resolving the issue.

Please let us know if you need any further assistance.

Regards,
Eswari.S



AC Anthony Constantinou August 16, 2011 12:33 PM UTC

Hi,

I am using Grid for Windows Forms, sorry I posted the question in the wrong forum.

Thanks,
Anthony



RB Ragamathulla B Syncfusion Team August 18, 2011 11:30 AM UTC

Hi Anthony,

We regret deeply for the delay.

The IFormatProvider interface supplies an object that provides formatting information for formatting and parsing operations. Formatting operations convert the value of a type to the string representation of that value. Typical formatting methods are the ToString methods of a type, as well as Format. Parsing operations convert the string representation of a value to a type with that value. Typical parsing methods are Parse and TryParse.

You can handle the TableControlDrawCellDisplayText event and conditionally set the e.Inner.DisplayText to "Yes" or "No".
Here is the code snippets:

GridTableCellStyleInfo style = (GridTableCellStyleInfo)e.Inner.Style;
if (style.TableCellIdentity.Column != null && style.TableCellIdentity.Column.Name == "History" && style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record)
{
if (e.Inner.Style.Text == "True")
{
e.Inner.DisplayText = "Yes" ;
}
else if (e.Inner.Style.Text == "False")
{
e.Inner.DisplayText = "No";
}

Please let me know if any other concern.

Regards,
Ragamathullah B.



MM Mrudang Majmudar August 25, 2011 05:11 PM UTC

i have similar requirement for WPF DataGrid.

basically i want to do custom formatting
with CellType = UpDownEdit

e.g

Also how to control increment size
for up/down



JJ Jawahar Jeevanandan J Syncfusion Team August 29, 2011 02:27 PM UTC

Hi Mrudang,

We can apply custom format to UpDownEdit control as follows.







Please find the sample attached in the below link.

Please let us know if you have any queries.

Thanks,
Jawahar.



UpDownControl_56cecb45.zip

Loader.
Live Chat Icon For mobile
Up arrow icon