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

DataBoundGrid currency cell type?

How do I change the cell type for a column in a databound grid? Thanks

4 Replies

Administrator March 16, 2004 07:23 AM UTC

You set the CellType property of the GridBoundColumn.StyleInfo of that column. Here is a KB link that shows code to set BackColor. http://www.syncfusion.com/Support/article.aspx?id=562 You would do the same for CellType. If you want the CellType to be "Currency", then you may need to set other properties as shown in the Grid\Samples\CellTypes\Currency sample.

Administrator March 16, 2004 10:34 PM UTC

I set the celltype like you said but it just throws an exception now... I looked at that example and it only looks like it works for a GridControl... Am I missing something? Is there a way to loop thorugh the values displayed so I can set there celltype and cellvalue appropriately in a DataBoundGrid? >You set the CellType property of the GridBoundColumn.StyleInfo of that column. Here is a KB link that shows code to set BackColor. > >http://www.syncfusion.com/Support/article.aspx?id=562 > >You would do the same for CellType. If you want the CellType to be "Currency", then you may need to set other properties as shown in the Grid\Samples\CellTypes\Currency sample.

Administrator March 16, 2004 10:47 PM UTC

I tried adding the following code and each call to the StyleInfo causes an error saying Object not set to an instance of an object... this.ticketGrid.GridBoundColumns["Face"].StyleInfo.CellValueType = typeof(double); this.ticketGrid.GridBoundColumns["Face"].StyleInfo.CellValue = 1; this.ticketGrid.GridBoundColumns["Face"].StyleInfo.CellType = "C"; this.ticketGrid.GridBoundColumns["Face"].StyleInfo.StrictValueType = false;

Administrator March 16, 2004 10:56 PM UTC

What kind of values are coming from your DataSource? Here is code that works for double values coming from the datasource in the attached sample. Dim style As GridStyleInfo = Me.gridDataBoundGrid1.Binder.InternalColumns("$amount").StyleInfo style.CellType = "Currency" style.CurrencyEdit.ClipMode = Syncfusion.Windows.Forms.Tools.CurrencyClipModes.ExcludeFormatting forum11780_1942.zip
Loader.
Live Chat Icon For mobile
Up arrow icon