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

Measure cell content width in own cell renderer

Hi, I implemented a cell renderer to render a hierachical grid derived from GridTextBoxCellRenderer. Everything works fine so far. Now I want to determine the total width of each cell to implement autosize column. I use the graphics routines of the base class to support themded drawing and righttoleft. Is there any method availabe to measure text width, checkbox width and so on? Thanks in advance! Christian

1 Reply

AD Administrator Syncfusion Team May 5, 2005 03:06 PM

To hook into the standard autosize (through grid.model.ColWidths.ResizeToFit), you can have your derived cellmodel class override CalculatePreferredCellSize and return the optimal size for your cell there. ColWidths.ResizeToFit will call this method when it needs to size your cell. If you have our source code, you can look at different override of this method to see how the grid source does this calculation. The grid does use this helper method, Syncfusion.Windows.Forms.WinFormsUtils.MeasureSampleWString, to do its calculations.

Loader.
Live Chat Icon For mobile
Up arrow icon