| [PARTIALLY SOLVED] BUG: BestFit and vbNewline
 
 Printed From: Codejock Forums
 Category:  Codejock Products
 Forum Name:  Report Control
 Forum Description:  Topics Related to Codejock Report Control
 URL: http://forum.codejock.com/forum_posts.asp?TID=14059
 Printed Date: 31 October 2025 at 12:37pm
 Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
 
 
 Topic: [PARTIALLY SOLVED] BUG: BestFit and vbNewline
 Posted By: jpbro
 Subject: [PARTIALLY SOLVED] BUG: BestFit and vbNewline
 Date Posted: 17 April 2009 at 10:04pm
 
 
        
          | When you call the BestFit method (or user double-clicks column separator) on a column with cells that contain vbNewline, the calculation includes the total length of all lines combined instead of the length of the longest individual line. 
 -------------
 Product: Xtreme SuitePro (ActiveX) version 16.2.6
 Platform: Windows XP - SP3
 
 Language: Visual Basic 6.0 SP6
 
 
 |  
 
 Replies:
 Posted By: jpbro
 Date Posted: 21 April 2009 at 5:10pm
 
 
        
          | Can I expect a fix for this in the next release? 
 -------------
 Product: Xtreme SuitePro (ActiveX) version 16.2.6
 Platform: Windows XP - SP3
 
 Language: Visual Basic 6.0 SP6
 
 
 |  
 Posted By: mdoubson
 Date Posted: 27 January 2010 at 6:08pm
 
 
        
          | this is usual way DrawText make DT_CALRECT-base best fit 
 -------------
 Mark Doubson, Ph.D.
 |  
 Posted By: jpbro
 Date Posted: 28 January 2010 at 2:22pm
 
 
        
          | Then either DrawText is broken, or using DrawText to calc the text rect for strings that contain newline characters is not the correct approach. Newline characters break the text rendering onto multiple lines. If DrawText doesn't calculate the best fit width properly, then maybe the item text needs to be split on newline characters, and each line measured independently. The longest width found would be the best fit for the cell. 
 
 -------------
 Product: Xtreme SuitePro (ActiveX) version 16.2.6
 Platform: Windows XP - SP3
 
 Language: Visual Basic 6.0 SP6
 
 
 |  
 Posted By: mdoubson
 Date Posted: 28 January 2010 at 2:53pm
 
 
        
          | DrawText complains should go to Microsoft I guess. In your case I think you can use markup with will keep extra CR/LF 
 -------------
 Mark Doubson, Ph.D.
 |  
 Posted By: mdoubson
 Date Posted: 28 January 2010 at 3:05pm
 
 
        
          | Btw - this is Excel style of cell text draw 
 -------------
 Mark Doubson, Ph.D.
 |  
 Posted By: jpbro
 Date Posted: 28 January 2010 at 6:12pm
 
 
        
          | It's not so much a DrawText/MS complaint as a BestFit/Codejock RC
complaint. The method is called BestFit, and it clearly doesn't
calculate the best fit for the cell. If DrawText wasn't designed to
handle newlines in its calculation
routines, then it is the incorrect choice for calculating text for an
object that supports newline characters. There are simple methods to
calculate the best fit for plain text (one approach was mentioned
above). 
 Other grids handle it fine (including VSFlexGrid OCX, OpenOffice.org
Calc). And, contrary to what you claim, Excel 2007 calculates best fit
with newlines properly too, so your statement about Excel is incorrect
at least for contemporary versions of the program.
 
 Excel 2007 after double-clicking the column divider (i.e. calculating best fit for column):
 
  
 
 VSFlexGrid OCX using the AutoSize method (i.e. Calculating best fit for a column):
 
 
  
 
 
 OpenOffice.org after double-clicking the column divider (i.e. calculating best fit for column):
 
  
 
 
 Codejock ReportControl after calling BestFit on a column with RecordItems that have newline characters:
 
  
 It's obvious which one is the odd man out, and which one is exhibiting unexpected behaviour. It seems excessive to have to add the overhead of Markup to an RC that otherwise doesn't require markup just to get expected best fit behaviour.
 
 
 -------------
 Product: Xtreme SuitePro (ActiveX) version 16.2.6
 Platform: Windows XP - SP3
 
 Language: Visual Basic 6.0 SP6
 
 
 |  
 Posted By: mdoubson
 Date Posted: 29 January 2010 at 12:25am
 
 
        
          | You right - need to fix this. Btw - I mean Excel 2003 of course. 
 -------------
 Mark Doubson, Ph.D.
 |  
 Posted By: mdoubson
 Date Posted: 29 January 2010 at 2:11am
 
 
        
          | Please try update:  https://forum.codejock.com/uploads/BetaOCX/ReportControlBeta14.rar - https://forum.codejock.com/uploads/BetaOCX/ReportControlBeta14.rar 
 -------------
 Mark Doubson, Ph.D.
 |  
 Posted By: McKloony
 Date Posted: 29 January 2010 at 3:50am
 
 
        
          | Do you have also a Beta for CalendarControl? 
 -------------
 Product: Xtreme SuitePro (ActiveX) 16.2.5
 
 Platform: XP / Windows 7
 
 Language: Visual Basic 6.0 SP6
 |  
 Posted By: mdoubson
 Date Posted: 29 January 2010 at 9:23am
 
 
        
          | Sure -  https://forum.codejock.com/uploads/BetaOCX/CalendarBeta14.rar - https://forum.codejock.com/uploads/BetaOCX/CalendarBeta14.rar 
 -------------
 Mark Doubson, Ph.D.
 |  
 Posted By: jpbro
 Date Posted: 30 January 2010 at 12:48pm
 
 
        
          | Sorry Mark, I didn't see the post with the rebuild - I've tested it and BestFit is performing nicely for all my tests so far, thank you very much. 
 A side note though - the algorithm that decides whether or not to show tooltip based on the width of the text isn't taking newlines into account, so the automatic tooltip is showing for multi-line items even when all the text appears within the cell boundaries. The automatic tooltip also displays newline characters as boxes instead of wrapping to a new line.
 
 You can kind of work around this by setting the Tooltip property of the recorditem to the recorditem value. This tooltip supports newlines by rendering each line separately. The only issues with this method are that the tooltip always shows on mouse hover, and the tooltip doesn't show over the cell like the automatic tooltip does (it is tracked to the mouse pointer position instead of the cell boundaries).
 
 
 -------------
 Product: Xtreme SuitePro (ActiveX) version 16.2.6
 Platform: Windows XP - SP3
 
 Language: Visual Basic 6.0 SP6
 
 
 |  
 Posted By: mdoubson
 Date Posted: 30 January 2010 at 8:23pm
 
 
        
          | RIght - it should be next step - tooltip can be multilined 
 -------------
 Mark Doubson, Ph.D.
 |  
 Posted By: jpbro
 Date Posted: 26 February 2010 at 5:03pm
 
 
        
          | Will the tooltip be multi-line aware for the next release? 
 
 
 -------------
 Product: Xtreme SuitePro (ActiveX) version 16.2.6
 Platform: Windows XP - SP3
 
 Language: Visual Basic 6.0 SP6
 
 
 |  
 
 |