Most developers have encountered a need at some point to modify how data is displayed to the user. The RadGridView offers a very straightforward way to format data without having to modify the source data. For example, you may not want the time displayed with a DateTime field, or you want to change the structure of the data to meet an internal standard. The screenshot below shows three different fields which display the default DateTime format.


This may be valid data, but it may not be useful to the user and we could potentially save screen real estate by eliminating unnecessary information. By using the FormatString property of the column you can apply the same standard formatting options available with the string.Format method.

radGridView1.Columns["OrderDate"].FormatString = "{0:dddd, MMM dd, yyyy}";  
radGridView1.Columns["RequiredDate"].FormatString = "{0:yyyy/MM/dd}";  
radGridView1.Columns["ShippedDate"].FormatString = "{0:dd - MM - yyyy}";  

The code shown will apply different custom formatting options, as seen below. The time data is no longer visible since we are specifically concerned with the date.


Formatting can is particularly useful when dealing with numeric data since it can represent currency, percentages and so on. Look at the Order Details table information below. The values are informative, but you could not know that 14.0000 is a dollar amount necessarily unless you looked at the column header.


By applying formatting we can make it much more readable for the user and give the visual hint of the type of information the user is looking at.

this.radGridView1.Columns["UnitPrice"].FormatString = "{0:$#,###0.00;($#,###0.00);0}";  
this.radGridView1.Columns["Quantity"].FormatString = "{0:#,###00 units}";  
this.radGridView1.Columns["Discount"].FormatString = "{0:#0%;(#0%);none}";  

The code above using the same formatting technique will allow the data to be represented more accurately. 


The simplicity of this feature makes it something you can implement with your existing or new applications quickly. To assist you in getting started I have outlined some handy references for the formatting options available.

DateTime Format Options

Number Format Options

About the Author

Nikolay Diyanov

Diyanov is the Product Manager of the Native Mobile UI division at Progress. Delivering outstanding solutions that make developers' lives easier is his passion and the biggest reward in his work. In his spare time, Nikolay enjoys travelling around the world, hiking, sun-bathing and kite-surfing.

Find him on Twitter @n_diyanov or on LinkedIn.

Related Posts


Comments are disabled in preview mode.