trichview.support
Re: divide table |
Author |
Message |
Sergey Tkachenko |
Posted: 03/13/2004 23:29:15 (I deleted your original post because of large attachement (please do post in trichview groups files larger than 30K)) I can suggest a procedure for dividing table into two tables between rows. Procedure for dividing inside table cells will be too complicated. And I am not completely understand where user should click. function SplitTable(rve: TCustomRichViewEdit; table: TRVTableItemInfo; RowCountInFirstTable: Integer; PageBreak: Boolean): Boolean; var r, c, mr, mc: Integer; newtable: TRVTableItemInfo; Stream: TMemoryStream; begin Result := False; if RowCountInFirstTable>=table.Rows.Count then exit; for c := 0 to table.Rows[0].Count-1 do if table.Cells[RowCountInFirstTable, c]=nil then begin table.Rows.GetMainCell(RowCountInFirstTable, c, mr, mc); if mr<RowCountInFirstTable then exit; end; Stream := TMemoryStream.Create; table.SaveRowsToStream(Stream, RowCountInFirstTable, table.Rows.Count-RowCountInFirstTable); Stream.Position := 0; newtable := TRVTableItemInfo.CreateEx(0, 0, rve.RVData); newtable.LoadFromStream(Stream); if PageBreak then newtable.PageBreakBefore := True; Stream.Free; rve.BeginUndoGroup(rvutModifyItem); rve.SetUndoGroupMode(True); try table.DeleteRows(RowCountInFirstTable, table.Rows.Count-RowCountInFirstTable, True); rve.SetSelectionBounds(table.GetMyItemNo, 1, table.GetMyItemNo, 1); rve.InsertItem('', newtable); finally rve.SetUndoGroupMode(False); end; Result := True; end; Parameters: rve - editor containing table; this is usually a result of RichViewEdit1.GetCurrentItemEx; table - the table to split The table will be divided into two tables. The first resulting table will have row count = RowCountInFirstTable, the second table will have row count = table.Rows.Count-RowCountInFirstTable. If PageBreak parameter is True, a page break will be inserted between tables. > I want make possible to split a table simply by clicking on it. The line > that the user clicked will be the position to split the table. > > How do I do this task? > > I sent two images: > - BEFORE.JPG that represents the act before splitting the table > - AFTER.JPG: represents the table after splitting > > > -------------------------------------------------------------------------- -- > ---- > > > |
Powered by ABC Amber Outlook Express Converter