Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
285
Can't get a grid to resize it's cells after changing DrawUtility.UseGDIPlusTextRendering
posted

I recently changed the default text rendering mode to GDI but I want to provide a user option to toggle it in case any users complain

Changing the mode does immediately update the text displayed in the cells correctly, but not the cell dimensions - the GDI+ version of the font is taller and slightly less wide. If the grid is recreated with the new setting it is very noticeably a different size.

However I can't force the grid to recalculate the size of the cells using the new text mode, I've tried various combinations of:

grid.DisplayLayout.UIElement.Invalidate(True)
grid.DisplayLayout.UIElement.DirtyChildElements()
grid.DisplayLayout.UIElement.VerifyChildElements(True)
grid.DisplayLayout.UIElement.ChildElements.Clear()
grid.DisplayLayout.UIElement.Dispose()
grid.Invalidate(True)  

All to no avail, the cells always remain the same size.

Also I concur with previous posts about how rubbish GDI+ looks (how on earth does the same font + size draw differently), even the infragistics menus look different from every other windows app because of this, and the ridiculous switching between edit mode means I have to disable it for everything.

thanks

    Martin 

Parents
  • 469350
    Verified Answer
    Offline posted

     Cells in the grid do not autosize based on the font, except once the first time they paint. So the code you have here won't work. If you want to autosize a column to it's contents, you need to call the PerformAutoResize method on the column. There is also a PerformAutoSize method on the row to adjust the height. 

    The latest version of the grid has methods like PerformAutoSizeColumns on the band and the layout, so you size all of the columns at once. 

Reply Children