I loop thru and load x number of cells in my richview.
I want to run another loop afterwards and update a line in each cell.
So if I wanted to say add some text to the beginning of the first line how would I do this? Would like an example. Thanks
Edit Line of a Cell
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Actually that will suffice
Yes that would help.
Basically each cell is loaded with a question. Because we randomly present the questions I don't know the question number before hand.
So after my cells are populated , I reloop thru then and update the current contents.
So for instance , if I have a cell that says 'What is 2 + 2?' then I want to edit the first line in the cell with a question number to look like '1: What is 2 + 2?'.
Basically each cell is loaded with a question. Because we randomly present the questions I don't know the question number before hand.
So after my cells are populated , I reloop thru then and update the current contents.
So for instance , if I have a cell that says 'What is 2 + 2?' then I want to edit the first line in the cell with a question number to look like '1: What is 2 + 2?'.
Just an idea.
This is not a very complicated task. You could create a TStringlist for all the questions. Loop through and gather all the questions by adding each one to the StringList and clearing the cells where the question was copied.
Make another loop and this time, random select the question from the TStringList, place it in the cell then delete it from the TStringList.
The next random means that there is less question until the TStringList has only two questions left.
The last question in the TStringList is for the last cell.
By clearing the cells means that you can add the question instead of inserting it.
Hope this idea is good for you.
Good luck.
This is not a very complicated task. You could create a TStringlist for all the questions. Loop through and gather all the questions by adding each one to the StringList and clearing the cells where the question was copied.
Make another loop and this time, random select the question from the TStringList, place it in the cell then delete it from the TStringList.
The next random means that there is less question until the TStringList has only two questions left.
The last question in the TStringList is for the last cell.
By clearing the cells means that you can add the question instead of inserting it.
Hope this idea is good for you.
Good luck.
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
If you just need to modify the existing text (not to insert new paragraphs or text of different font), it is very simple.
This code adds numbers to the first columns of each table in the document (nested tables are ignored).
This code adds numbers to the first columns of each table in the document (nested tables are ignored).
Code: Select all
var i, r, idx: Integer;
table: TRVTableItemInfo;
for i := 0 to rv.ItemCount-1 do
if rv.GetItemStyle(i)=rvsTable then begin
table := TRVTableItemInfo(rv.GetItem(i));
idx := 1;
for r := 0 to table.RowCount-1 do
if (table.Cells[r,0]<>nil) and
(table.Cells[r,0].GetRVData.GetItemStyle(0)>=0) then begin
s := table.Cells[r,0].GetRVData.GetItemTextA(0);
table.Cells[r,0].GetRVData.SetItemTextA(0, IntToStr(idx)+': '+s);
inc(idx);
end;
end;
rv.Format;