Using HTML in Grid

Hi,

I have set Options.Cell.DisplayHTMLFormatting to true but when I set a cell by code using say:

 gNews.Cells[X,Y]:=FormatDateTime('d mmm, hh:nn',PublishedDate)+' '+
        '<A href="'+Link+'">Link</A>';

It does not display a link.

Am I missing something?

Thanks,

Ken


Sorry, it does work. I misunderstood the use of DisplayHTMLFormatted (it isn't mentioned in the help). However, the hyperlink cannot be clicked on and neither does the OnCellAnchorClick fire.

Tested this here but we are not able to reproduce this. Please provide a sample.

Default grid on the form, with the following code:



procedure TForm17.FormCreate(Sender: TObject);
begin
TMSFNCGrid1.Cells[1,1]:=FormatDateTime('d mmm, hh:nn',Now)+' '+
        '<A href="http://www.tmssoftware.com">Link</A>';
        TMSFNCGrid1.AutoSizeGrid();
end;

If I call AutoSizeGrid it does indeed work but I do not want it auto sized.I am doing everything within a beginupdate endupdate block so how can I get it to work?

can you post the code that makes it fail?

 gNews.BeginUpdate;
 gNews.Clear;
 gNews.RowCount:=Query.RecordCount+1;
 gNews.FontStyles[0,0]:=[];
 gNews.Cells[0,0]:='Date/Source';
 gNews.FontStyles[1,0]:=[];
 gNews.Cells[1,0]:='Latest News';
  I:=0;
  while not Query.EOF do
  begin
    Inc(I);
    gNews.FontStyles[0,I]:=[];
    gNews.Cells[0,I]:=FormatDateTime('d mmm, hh:nn',Query.FieldByName('Published').AsDateTime)+' '+
        '<A href="'+Query.FieldByName('Link').AsString+'">'+Query.FieldByName('Source').AsString+'</A>';
      gNews.Cells[1,I]:=Query.FieldByName('Title').AsString;
    Query.Next;
  end;
  gNews.EndUpdate;

a code snippet that is reproducible without having to setup a database please. Did you have other properties set? is this is default grid? 

If you set the column width to a small size,, such as 80, so that it is forced to wrap, it stops working.

Changing +' '+ to +'<BR>'+ forces it to work correctly.

Hi,


This is related to the internal HTML engine. We'll investigate what is going wrong exactly.