try
var
r,c,w : Integer;
begin
for c:=0 to StringGrid1.ColCount-1 do begin
w:=20; // min width
for r:=0 to StringGrid1.RowCount-1 do
if StringGrid1.Canvas.TextWidth(StringGrid1.Cells[c,r])>w then
w:=StringGrid1.Canvas.TextWidth(StringGrid1.Cells[c,r]);
StringGrid1.ColWidths[c]:=w+5;
end;
end;
Then again you could use a third part component like TAdvStringGrid which
has a AutoSizeColumns(False,5) property;
Warren
-----Original Message-----
From: Chris Veale [mailto:[EMAIL PROTECTED]
Sent: Thursday, 24 July 2003 01:34 p.m.
To: Multiple recipients of list delphi
Subject: [DUG]: tstringgrid column width.
Hi.
Is there any way to adjust the column width of a tstringgrid based on the
longest string entered in the column?
Im getting text cut off that id like to display but cant see any place of
changing it aside from defaultcolwidth property which changes all columns.
Cheers
Chris Veale
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.502 / Virus Database: 300 - Release Date: 18/07/03
______________________________________________________
The contents of this e-mail are privileged and/or confidential to the
named recipient and are not to be used by any other person and/or
organisation. If you have received this e-mail in error, please notify
the sender and delete all material pertaining to this e-mail.
______________________________________________________
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared
by MailMarshal
For more information please visit www.marshalsoftware.com
#####################################################################################
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/