Does anyone know of a way to make stringgrid columns automatically re-size to the length of the longest string in the column. (like when you double click on the line between columns in excel).
Yep. Something like this.
Be aware of error in the example, this was taken right from the head... ;-)
You have to bundle this loop into a loop for every existing colmn...
Code:
n := 0;
for i := 0 to StringGrid1.RowCount -1 do
begin
if StringGrid1.Canvas.TextWidth(Stringrid1.Cells[0, i]) > n then
n := StringGrid1.Canvas.TextWidth(Stringrid1.Cells[0, i])
end;
StringGrid1.ColWidths[0] := n
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There is always another way to solve it, but I prefer my way.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.