ysimon
asked on
No Scrolling in RichEdit
In RichEdit, I would like to keep whole text no scrolling when it is updated. How should I do.
What do you mean with 'updated'?
I know what he means..
In the RichEdit as with TMemo, when you programatically dump alot of text in the box the cursor goes to the end.
I believe he wants to reposition the cursor to it's original spot.
FROM THE HELP FILE
Read SelStart ...
If there is no selected text, SelStart indicates the position of the cursor. Set SelStart to remove the current selection and position the cursor just before the indicated character.
Try this ...
Richedit1.loadfromfile(bla h.rtf');
Richedit1.SelStart := 0;
In the RichEdit as with TMemo, when you programatically dump alot of text in the box the cursor goes to the end.
I believe he wants to reposition the cursor to it's original spot.
FROM THE HELP FILE
Read SelStart ...
If there is no selected text, SelStart indicates the position of the cursor. Set SelStart to remove the current selection and position the cursor just before the indicated character.
Try this ...
Richedit1.loadfromfile(bla
Richedit1.SelStart := 0;
Um...
Richedit1.loadfromfile(bla h.rtf');
Richedit1.SelStart := 0;
RichEdit1.SelLength := 0; // avoid selecting text
Don
Richedit1.loadfromfile(bla
Richedit1.SelStart := 0;
RichEdit1.SelLength := 0; // avoid selecting text
Don
ASKER
The text in RichEdit was written via a set of RichEdit1.Lines.Append('Te xt');
Another Update button will reload that set of RichEdit1.Lines.Append('Te xt');
Each time, it will go to the last line. I would like to keep the current viewing position. Is that possible?
ysimon
Another Update button will reload that set of RichEdit1.Lines.Append('Te
Each time, it will go to the last line. I would like to keep the current viewing position. Is that possible?
ysimon
I would add to the above:
with richEdit1.lines do
begin
beginUpdate;
append('text');
selStart := 0;
endUpdate;
end;
This way there is no rawing done until everything is finalized.
GL
Mike
with richEdit1.lines do
begin
beginUpdate;
append('text');
selStart := 0;
endUpdate;
end;
This way there is no rawing done until everything is finalized.
GL
Mike
procedure addtext();
var cpos: integer;
with Richedit1 do
begin
cpos := selstart; // get starting position
Lines.Append('Text'); // add text
SelStart := cpos; //reset starting position
SelLength := 0; // no selected text when finished.
end;
end;
** Edey: I trust that is important but I'm still kinda new, what might happen?
Don
procedure addtext();
var cpos: integer;
with Richedit1 do
begin
cpos := selstart; // get starting position
Lines.Append('Text'); // add text
SelStart := cpos; //reset starting position
SelLength := 0; // no selected text when finished.
end;
end;
** Edey: I trust that is important but I'm still kinda new, what might happen?
Don
um, don't refresh after posting :)
ALSO note that there shouls be a ; after the
var cpos: integer;
The comma snuck in there.
Don
ALSO note that there shouls be a ; after the
var cpos: integer;
The comma snuck in there.
Don
ASKER
Have you tried
procedure addtext();
var cpos, I: integer;
with Richedit1 do
begin
cpos := selstart; // get starting position
for I:=1 to 100 do
Lines.Append('Text'); // add text
SelStart := cpos; //reset starting position
SelLength := 0; // no selected text when finished.
end;
end;
procedure addtext();
var cpos, I: integer;
with Richedit1 do
begin
cpos := selstart; // get starting position
for I:=1 to 100 do
Lines.Append('Text'); // add text
SelStart := cpos; //reset starting position
SelLength := 0; // no selected text when finished.
end;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sweet. Thanks for the tip :)
Glad to be of service :)
GL
Mike
GL
Mike
ASKER
If using
memo1.lines.beginUpdate;
memo1.Lines.Clear;
for ix := 0 to 1000 do
memo1.Lines.Append(chr(ord ('a')+rand om(26));
memo1.lines.endUpdate;
Can it stop at the current viewing position?
ysimon
memo1.lines.beginUpdate;
memo1.Lines.Clear;
for ix := 0 to 1000 do
memo1.Lines.Append(chr(ord
memo1.lines.endUpdate;
Can it stop at the current viewing position?
ysimon
Yup, the logic is the same as before:
memo1.lines.beginUpdate;
startPos := memo1.selStart;
for ix := 0 to 1000 do
memo1.Lines.Append(chr(ord ('a')+rand om(26));
memo1.selStart := startPos;
memo1.lines.endUpdate;
GL
Mike
memo1.lines.beginUpdate;
startPos := memo1.selStart;
for ix := 0 to 1000 do
memo1.Lines.Append(chr(ord
memo1.selStart := startPos;
memo1.lines.endUpdate;
GL
Mike
ASKER
Yes, you are right.
In my case, it always goes to the end after For Loop.
I have to find why.
ysimon
In my case, it always goes to the end after For Loop.
I have to find why.
ysimon
ASKER
I found why it always go to end. Because I set vertical scollbar. If set to None, like your example, it will stay at beginning. Any suggestion?
ysimon
ysimon
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY. Moderators Computer101 or Netminder will return to finalize these if still open in seven days. Please post closing recommendations before that time.
Question(s) below appears to have been abandoned. Your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.
For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process. https://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp
Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site. If you are an EE Pro user, use the Power Search option to find them.
To view your open questions, please click the following link(s) and keep them all current with updates.
https://www.experts-exchange.com/questions/Q.11866558.html
https://www.experts-exchange.com/questions/Q.20107980.html
https://www.experts-exchange.com/questions/Q.20112507.html
https://www.experts-exchange.com/questions/Q.20121203.html
https://www.experts-exchange.com/questions/Q.20122370.html
https://www.experts-exchange.com/questions/Q.20128022.html
https://www.experts-exchange.com/questions/Q.20128024.html
https://www.experts-exchange.com/questions/Q.20143035.html
https://www.experts-exchange.com/questions/Q.20145949.html
https://www.experts-exchange.com/questions/Q.20164917.html
https://www.experts-exchange.com/questions/Q.20164983.html
https://www.experts-exchange.com/questions/Q.20171798.html
https://www.experts-exchange.com/questions/Q.20179154.html
https://www.experts-exchange.com/questions/Q.20192667.html
https://www.experts-exchange.com/questions/Q.20192583.html
https://www.experts-exchange.com/questions/Q.20200806.html
https://www.experts-exchange.com/questions/Q.20201786.html
https://www.experts-exchange.com/questions/Q.20201947.html
https://www.experts-exchange.com/questions/Q.20246959.html
https://www.experts-exchange.com/questions/Q.20252474.html
https://www.experts-exchange.com/questions/Q.20259886.html
https://www.experts-exchange.com/questions/Q.20270462.html
https://www.experts-exchange.com/questions/Q.20273241.html
To view your locked questions, please click the following link(s) and evaluate the proposed answer.
https://www.experts-exchange.com/questions/Q.20265181.html
https://www.experts-exchange.com/questions/Q.20277546.html
PLEASE DO NOT AWARD THE POINTS TO ME.
------------> EXPERTS: Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days. Also, if you are interested in the cleanup effort, please click this link https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
Thank you everyone.
Moondancer
Moderator @ Experts Exchange
P.S. For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
Question(s) below appears to have been abandoned. Your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.
For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process. https://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp
Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site. If you are an EE Pro user, use the Power Search option to find them.
To view your open questions, please click the following link(s) and keep them all current with updates.
https://www.experts-exchange.com/questions/Q.11866558.html
https://www.experts-exchange.com/questions/Q.20107980.html
https://www.experts-exchange.com/questions/Q.20112507.html
https://www.experts-exchange.com/questions/Q.20121203.html
https://www.experts-exchange.com/questions/Q.20122370.html
https://www.experts-exchange.com/questions/Q.20128022.html
https://www.experts-exchange.com/questions/Q.20128024.html
https://www.experts-exchange.com/questions/Q.20143035.html
https://www.experts-exchange.com/questions/Q.20145949.html
https://www.experts-exchange.com/questions/Q.20164917.html
https://www.experts-exchange.com/questions/Q.20164983.html
https://www.experts-exchange.com/questions/Q.20171798.html
https://www.experts-exchange.com/questions/Q.20179154.html
https://www.experts-exchange.com/questions/Q.20192667.html
https://www.experts-exchange.com/questions/Q.20192583.html
https://www.experts-exchange.com/questions/Q.20200806.html
https://www.experts-exchange.com/questions/Q.20201786.html
https://www.experts-exchange.com/questions/Q.20201947.html
https://www.experts-exchange.com/questions/Q.20246959.html
https://www.experts-exchange.com/questions/Q.20252474.html
https://www.experts-exchange.com/questions/Q.20259886.html
https://www.experts-exchange.com/questions/Q.20270462.html
https://www.experts-exchange.com/questions/Q.20273241.html
To view your locked questions, please click the following link(s) and evaluate the proposed answer.
https://www.experts-exchange.com/questions/Q.20265181.html
https://www.experts-exchange.com/questions/Q.20277546.html
PLEASE DO NOT AWARD THE POINTS TO ME.
------------> EXPERTS: Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days. Also, if you are interested in the cleanup effort, please click this link https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
Thank you everyone.
Moondancer
Moderator @ Experts Exchange
P.S. For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
Zero response from anyone, finalized.
Moondancer - EE Moderator
Moondancer - EE Moderator