Ask how to use OnDrawBorder of tables
Posted: Thu Aug 03, 2006 2:10 am
I write code,but it doesn't work,delphi doesn't execute doDrawBorder.
//Create the table
procedure TForm1.mitInserttable1Click(Sender: TObject);
var table: TRVTableItemInfo;
r,c: Integer;
begin
table := TRVTableItemInfo.CreateEx(4,3, RichViewEdit1.RVData);
table.OnDrawBorder:=DoDrawBorder;
table.BorderStyle := rvtbRaisedColor;
table.CellBorderStyle := rvtbLoweredColor;
table.BorderLightColor := $00FAF1C9;
table.BorderColor := $00A98E10;
table.CellBorderLightColor := $00FAF1C9;
table.CellBorderColor := $00A98E10;
table.Color := $00EAC724;
table.BorderWidth := 5;
table.CellBorderWidth := 2;
table.CellPadding := 5;
table.CellVSpacing := 1;
table.CellHSpacing := 1;
table.BorderVSpacing := 1;
table.BorderHSpacing := 1;
for r := 0 to table.Rows.Count-1 do
for c := 0 to table.Rows[r].Count-1 do
table.Cells[r,c].BestWidth := 100;
table.MergeCells(0,0,3,1, False);
table.MergeCells(1,0,1,3, False);
with table.Cells[0,0] do begin
Color := clInfoBk;
Clear;
AddBulletEx( '',0,il,2);
AddNL(' Example 1 ',1,-1);
AddBulletEx( '',0,il,-1);
AddNL('All cells have 100 pixels width, width of table itself is calculated basing on width of cells.',0,0);
end;
if RichViewEdit1.InsertItem('', table) then begin
end;
end;
//draw border procedure
procedure TForm1.DoDrawBorder(Sender: TRVTableItemInfo;
Canvas: TCanvas; Left,Top,Right,Bottom, Width: Integer;
LightColor, Color, BackgroundColor: TColor;
Style: TRVTableBorderStyle; Printing: Boolean;
VisibleBorders: TRVBooleanRect; Row, Col: Integer;
var DoDefault: Boolean);
begin
if Width=0 then
exit;
inc(Right);
inc(Bottom);
Canvas.Pen.Color := Color;
Canvas.Pen.Style := psInsideFrame;
Canvas.Pen.Width := 1;
Canvas.Brush.Style := bsClear;
Canvas.Rectangle(Left,Top,Right,Bottom);
DoDefault := False;
end;
//Create the table
procedure TForm1.mitInserttable1Click(Sender: TObject);
var table: TRVTableItemInfo;
r,c: Integer;
begin
table := TRVTableItemInfo.CreateEx(4,3, RichViewEdit1.RVData);
table.OnDrawBorder:=DoDrawBorder;
table.BorderStyle := rvtbRaisedColor;
table.CellBorderStyle := rvtbLoweredColor;
table.BorderLightColor := $00FAF1C9;
table.BorderColor := $00A98E10;
table.CellBorderLightColor := $00FAF1C9;
table.CellBorderColor := $00A98E10;
table.Color := $00EAC724;
table.BorderWidth := 5;
table.CellBorderWidth := 2;
table.CellPadding := 5;
table.CellVSpacing := 1;
table.CellHSpacing := 1;
table.BorderVSpacing := 1;
table.BorderHSpacing := 1;
for r := 0 to table.Rows.Count-1 do
for c := 0 to table.Rows[r].Count-1 do
table.Cells[r,c].BestWidth := 100;
table.MergeCells(0,0,3,1, False);
table.MergeCells(1,0,1,3, False);
with table.Cells[0,0] do begin
Color := clInfoBk;
Clear;
AddBulletEx( '',0,il,2);
AddNL(' Example 1 ',1,-1);
AddBulletEx( '',0,il,-1);
AddNL('All cells have 100 pixels width, width of table itself is calculated basing on width of cells.',0,0);
end;
if RichViewEdit1.InsertItem('', table) then begin
end;
end;
//draw border procedure
procedure TForm1.DoDrawBorder(Sender: TRVTableItemInfo;
Canvas: TCanvas; Left,Top,Right,Bottom, Width: Integer;
LightColor, Color, BackgroundColor: TColor;
Style: TRVTableBorderStyle; Printing: Boolean;
VisibleBorders: TRVBooleanRect; Row, Col: Integer;
var DoDefault: Boolean);
begin
if Width=0 then
exit;
inc(Right);
inc(Bottom);
Canvas.Pen.Color := Color;
Canvas.Pen.Style := psInsideFrame;
Canvas.Pen.Width := 1;
Canvas.Brush.Style := bsClear;
Canvas.Rectangle(Left,Top,Right,Bottom);
DoDefault := False;
end;