Hi !
I have a TAdvStringGrid with about 200 pics wide fixed-column (if normal col it is ok)
I would like to show a name on top left corner of the cell and a number associated to the name on the bottom right corner of the cell. On the OnGetDispText-event I have:
Value:='<P align="left">'+name+'</P>'+'<P align="right">' + number+'</P>';
Problem is that the number will not show only the name. This two left and right-aligned paragraph version works well in grid versions 2009 but not anymore.
Now I must use the form:
Value:='<SUP>'+name+'</SUP>'+'<SUB> <P align="right">' + number+'</P></SUB>';
to get the number visible.
This superscript & subscript version however has two problems:
- the name is center aligned not left
-if the name is too long, it will be cut, but the number will not visible
What is the correct way to show left and right aligned text in a fixed cell.?
This is unfortunately not possible. The paragraph tag <P> creates a new paragraph, i.e. a new line. It's not possible to combine a paragraph left and right on the same line.
Hi !
I have tried to insert line break tag <BR> between paragraphs, but no help. As I said this worked about 2 years ago version, something has happened to AdvStringGrid in HTML-formatted text display.
And it works with normat cells, not with fixed cells ! Why !
Can't see any problem with the code:
procedure TForm4.Button1Click(Sender: TObject);
begin
advstringgrid1.RowHeights[0] := 40;
advstringgrid1.Cells[1,0] := 'Line1<BR>Line2';
end;
it shows two lines in the fixed cell.
Thanks Bruno, now I know how to get it working:
value='top left text<BR>'<P align="right">'+'bottom right'+'</P>';
However, it depends whether the font style is bold/norma/italic, what is the row height and whether it is fixed or normal column. To demonstrate this do the following:
Place a grid in a form, set col=0 (fixed) width=160 and col=1 width=160
add these 2 events:
procedure TForm1.gridGetCellColor(Sender: TObject; ARow, ACol: Integer;
AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
if arow mod 3 =1 then afont.Style:=[fsitalic];
if arow mod 3 =2 then afont.Style:=[fsbold];
end;
procedure TForm1.gridGetDisplText(Sender: TObject; ACol, ARow: Integer;
var Value: string);
begin
if acol=0 then begin
VALUE:='top left very long long long text'+'<BR>';
VALUE:=VALUE+'<P align="right">'+'bottom right'+'</P>';
end;
if acol=1 then begin
VALUE:='top left very long long long text'+'<BR>';
VALUE:=VALUE+'<P align="right">'+'bottom right'+'</P>';
end;
end;
Leave defaultRowHeight to 30 and run
- normal&iltalic text show correclty on col =1 but NOT on col=0, why ?
Set defaultRowHeight to 35 and run
-italic text on col 0 shows correclty but not bold because it wraps to next line
-bold text wraps differently on fixed/normal cell, why ?
setting fixedColWidht to 200 shows also bold text on fixed col correctly !
The inner display rect. within a fixed cell is a pixel or 2 smaller due to the shadow/shine on the border.