ReRe: Right align column of Delphi stringgrid

Posted by robert on September 16, 2005

In Reply to: Re: Right align column of Delphi stringgrid posted by Jenny on September 15, 2005

Sorry but i open the file to read a matrix and put in the grid after create form. I open the file using opendialog and read the name of variables and after the grid in the form and I write in the columns of the grid the name of variables and in the rows the number of rows. If I write the code below it still stay left align in the col 0 and when open file I get in the first rows second column a thing like:

#$0#0#0#0'riable '#0#0#0, where riable is part of the name of the variable. I don't know if you can understand me. Sorry for my bad english

: var R: integer;
: begin
: for R := 1 to Grid.RowCount - 1 do
: Grid.Cells[0, R] := IntToStr(R);

: However, this does not right-align these numbers. If you also want to right-align column 0, just add 1 line to your OnDraw event handler:

: if Grid.Cells[ACol,ARow] '' then begin
: bEsNum := True;
: sCad := Grid.Cells[ACol,ARow];
: if ACol > 0 then // add this line
: // and leave the rest as it was