Highlight current table row

<< Click to Display Table of Contents >>

Navigation:  Programming > User Interface >

Highlight current table row

With WPTools you can implement that the current row in a table is highlighted.

 

Either use the ViewOptionEx wpShowCurrentRowAsSelected (also possible for Cell and Table) or, if you need more control, use the owner paint event CustomLinePaintBefore:

 

procedure TForm1.WPRichText1CustomLinePaintBefore(Sender: TObject;

 RTFEngine: TWPRTFEngineBasis; param: TWPVirtPagePaintParam;

 EndOfPageRun: Boolean);

begin

if (WPRichText1.TableRow<>nil) and

      WPRichText1.TableRow.Contains(Param.Par) then

begin

   Param.Canvas.Brush.Style := bsSolid;

   Param.Canvas.Brush.Color := $eaefea;

   Param.Canvas.FillRect(Param.Rect);

end;

end;

 

 

To make sure the background is updated when required you also need to use the event ChangeCursorPos:

 

var fLastRow : TParagraph;

 

procedure TForm5.WPRichText1ChangeCursorPos(Sender: TObject);

var aRow : TParagraph;

begin

 aRow := WPRichText1.TableRow;

if aRow<>fLastRow then

begin

   fLastRow := aRow;

   WPRichText1.Repaint;

end;

end;