TAdvStringGrid
Example 8 : RTF display capabilities
This project is a simple application that shows the RTF display capabilities of TAdvStringGrid. As input for this demo, an Excel like approach is chosen, where a single editor sets the text for each cell. Two methods are available to transfer rich text to and from a rich edit control:procedure CellToRich(acol,arow:integer;arichedit:trichedit);
procedure RichToCell(acol,arow:integer;arichedit:trichedit);
These two methods are used to connect the rich edit control to the grid. In the OnSelectCell event handler, text from the selected cell is transfered to the edit control, while the OnClick event handler of the update speedbutton transfers the current rich edit content back to the selected cell.
Rich text as well as not rich text can be mixed in the grid. The grid automatically detects if the cell contains rich edit text or not. To update a cell with non rich text; simply use the normal approach:
TAdvStringGrid.Cells[ACol,ARow] := "Test";
var s:string; begin TAdvStringGrid.CellToRich(1,1,richedit1); s := richedit1.text; end;
Finally, full rich formatting can be saved as well to CSV files or being loaded from CSV files. Make sure though the MultiLineCells property is set true.
Delphi project & source files for downloading included in the main demos distribution for Delphi.
×