StringGrid WordWrap

Publication: C++ Builder Developer's Journal
Issue: Volume 10, Number 1, January 2006

In this 4 page article I jump into the VCL and Windows API and show the reader how to manipulate a string control with the Device Context. Sub headings include

  • The onDrawCell Event
  • Framing, formatting, and erasing the background

Recently, I saw a TidBit in the Journal about how to automatically resize a string grid’s column to fit a text label. In some cases this is a desirable effect, however in some cases it is not. Consider Figure A in which we have a fairly lengthy two word header label for a data column that contains only single character text. It’s a waste of screen realestate to widen the column to fully display the header label when the rest of the data for the column are only one character wide. But then it would be rather annoying to compress the width of the column for the single character and miss out on seeing the full title of the label.