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

Display Truncated Numeric as "######"

Hello, I have an application that uses the SyncFusion GridControl (Not Bound Grid) that has many columns of financial data. When values that are too big to display in the set column width they are truncated. In many cases, it is next to impossible to know that the visual data is not complete. I have looked through many of the properties for the GridCOntrol and did not find anything that looks like it would help. I did see the example in the knowledege base about haow to display elipsis on a Bound Data Grid but I would rather show "#######" instead. Anybody have a clue on how to achieve this? Thank you for your time and attention in advance, Scott #s

3 Replies

AD Administrator Syncfusion Team September 21, 2004 07:53 AM

Scott, I accomplished this by creating my own custom cell, overriding the draw method and measuring the text before calling DrawString. If the text does not fit, modify (with #''s) before calling DrawString. You can probably find a custom cell example in the Syncfusion examples. To speed things up, you can store the modified text and reset this variable based on column width change events, for example. Good Luck. Steve


AD Administrator Syncfusion Team September 21, 2004 08:56 AM

One event that works for any cell type (so you don''t have to derive a cell type) is the DrawCellDisplayText event. From within that event you can call the static GridStaticCellRenderer.DrawText method and afterwards set e.Cancel = true to prevent the grid from calling GridStaticCellRenderer.DrawText again when the event returns. Stefan


SN Scott Numbers October 5, 2004 11:18 AM

Thanks for the response. I used the Grid_DrawCell Event and it did the trick. This event was good because it provided easy access to the cell contents, the cell rectangle and a graphics object to do the measurement. Brief Sample: SizeF sz = e.Graphics.MeasureString(e.Style.CellValue.ToString(), mNumericFont); if ((sz.Width + 2) > e.Bounds.Width) { e.Style.CellValue = "################"; } Thanks again. >One event that works for any cell type (so you don''t have to derive a cell type) is the DrawCellDisplayText event. > >From within that event you can call the static GridStaticCellRenderer.DrawText method and afterwards set e.Cancel = true to prevent the grid from calling GridStaticCellRenderer.DrawText again when the event returns. > >Stefan

Loader.
Live Chat Icon For mobile
Up arrow icon