Merge cells
-
- Posts: 75
- Joined: Fri Jan 06, 2012 8:13 pm
Merge cells
Hi,
I have a table with 3 cols in row.
I want merge cells 1,2 together in rows 0,1,2 and merge cells 0,1 in rows 3,4,5 and again merge cells 1,2 in rows 6,7,8 and so on.
but when use
when row is 0,1,2,6,7,8
table.MergeCells(row,1,2,1,true);
when row is 3,4,5
table.MergeCells(row,0,2,1,true); <-- beep and does not work;
Please guide me
I have a table with 3 cols in row.
I want merge cells 1,2 together in rows 0,1,2 and merge cells 0,1 in rows 3,4,5 and again merge cells 1,2 in rows 6,7,8 and so on.
but when use
when row is 0,1,2,6,7,8
table.MergeCells(row,1,2,1,true);
when row is 3,4,5
table.MergeCells(row,0,2,1,true); <-- beep and does not work;
Please guide me
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I tried:
This code works as expected.
Code: Select all
var table: TRVTableItemInfo;
begin
table := TRVTableItemInfo.CreateEx(9, 3, RichViewEdit1.RVData);
table.MergeCells(0, 1,2,1,true);
table.MergeCells(1, 1,2,1,true);
table.MergeCells(2, 1,2,1,true);
table.MergeCells(3, 0,2,1,true);
table.MergeCells(4, 0,2,1,true);
table.MergeCells(5, 0,2,1,true);
table.MergeCells(6, 1,2,1,true);
table.MergeCells(7, 1,2,1,true);
table.MergeCells(8, 1,2,1,true);
table.CellBorderWidth := 1;
RichViewEdit1.InsertItem('', table)
end;
-
- Posts: 75
- Joined: Fri Jan 06, 2012 8:13 pm
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 75
- Joined: Fri Jan 06, 2012 8:13 pm
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
For example, you can use 1x1 table for each message, and draw table background.
Simple text for inserting table in RichViewEdit. This table shows rounded rectangle as a background:
Some additional measures should be taken if cells can be edited, but, as I understand, you do not need editing these tables.
Note that OnDrawBorder for a table is called before drawing the table content, so it can be used for drawing background.
Simple text for inserting table in RichViewEdit. This table shows rounded rectangle as a background:
Code: Select all
procedure TForm3.ToolButton68Click(Sender: TObject);
var table: TRVTableItemInfo;
begin
table := TRVTableItemInfo.CreateEx(1,1, RichViewEdit1.RVData);
table.OnDrawBorder := DrawTableBorder;
RichViewEdit1.InsertItem('', table)
end;
procedure TForm3.DrawTableBorder(Sender: TRVTableItemInfo;
Canvas: TCanvas; Left,Top,Right,Bottom: Integer;
Width: TRVStyleLength;
LightColor, Color, BackgroundColor: TColor;
Style: TRVTableBorderStyle; Printing: Boolean;
VisibleBorders: TRVBooleanRect; Row, Col: Integer;
var DoDefault: Boolean);
begin
if Row>=0 then
exit;
Canvas.Pen.Color := clRed;
Canvas.Pen.Style := psSolid;
Canvas.Pen.Width := 1;
Canvas.Brush.Color := clYellow;
Canvas.Brush.Style := bsSolid;
Canvas.RoundRect(Left, Top, Right, Bottom, (Right-Left) div 2, (Bottom-Top) div 2);
DoDefault := False;
end;
Note that OnDrawBorder for a table is called before drawing the table content, so it can be used for drawing background.
-
- Posts: 75
- Joined: Fri Jan 06, 2012 8:13 pm
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
It's strange, I looked in the code of TRichView 14, it draws table border before (i.e. below) contents too.
Do you added the code
?
Cell borders are drawn after (i.e. above) the cell content.
Do you added the code
Code: Select all
if Row>=0 then
exit;
Cell borders are drawn after (i.e. above) the cell content.
-
- Posts: 75
- Joined: Fri Jan 06, 2012 8:13 pm