LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Auto Sizing Table Cells Height and Width

Marcel,
 
If you need to call this function frequently, and performance is a concern, one suggestion I would make would be to not create the textbox each time. You could create it the first time you need it, and then discard it when your program exits. That will save some time.
 
Another suggestion would be to create the textbox in a separate, dedicated panel, that you never make visible. I can see that you placed the textbox in a location where the user never sees it, which is fine, but there is still some additional slowness associated with having the control in a visible panel, and which already contains other controls.
 
Luis
0 Kudos
Message 11 of 14
(1,408 Views)
Yes, as all this is really just a side-quest of my real work the function was more or less a quick hack. I've improved it a bit now performance wise, but some quick profiling shows that it's still between 4 and 10 times slower than just setting the text alone. Unfortunatelly this is still not acceptable for some cases.

In case anybody wonders, roughly 2/5 of the additional time is spend setting the font, 2/5 setting the text control width and 1/5 setting the text and reading back the number of lines. Not setting the font would be an option to speed it up but also too special-case this generic purpose function for my taste.

Oh, and unlike the first this new version is of course not at all thread-safe! I'm still trying to decide whether I can live with that (the otherwise needed synchronisation of course introducing yet another performance bottleneck...).

Marcel
Message 12 of 14
(1,396 Views)

There is a function SetColumnWidthToWidestCellContents to adjust the column width automatically. It's actually in the "Trees" library, but if works for tables too. Unfortunately there is no SetRowHeightToHighestCellContents or some function like that Smiley Sad

 


I know this is a very old thread, but for those out there that have searched for this like me, National Instruments did indeed add the function mentioned by Wim S above! 

 

 

SetRowHeightToTallestCellContents

 

Message 13 of 14
(666 Views)

Hi,

 

SetRowHeightToTallestCellContents is the function I was looking for but I think there is a problem.

The function sets the height of the rows also counting the hidden columns and this makes it unusable.

Is there a solution?

 

Thank you all

 

Message 14 of 14
(484 Views)