Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to delete last line of Tmemo

Status
Not open for further replies.

Ruggie

Programmer
Aug 2, 2003
46
US
This is what I'm doing:
I have two TMemos, Memo1 and Memo2
Memo1 is filled with information
I use the command Memo2->Lines->Add to add only a few lines of Memo1

The problem is that every time I add the lines to Memo2 there is a blank empty line at the end of Memo2 (that I didn't add)

So I try the command:
Memo2->Lines->Delete(Memo2->Lines->Count);
And nothing happens, but if I run:
Memo2->Lines->Delete(Memo2->Lines->Count - 1);
It removes the second to the last line.
(the line that has my data on it)
~
Heres an example of the data I'm working with:
~
Memo1:
Line 1
Line 2
Line 3
Line 4

Then I use the Add command to fill Memo2 like this:
Line 1
Line 3
<-- Undesired Empty Line

The problem is that its adding a line return and I can't get rid of it!

If you can shed some light on this please do, I don't know why the delete command isn't removing that last line.
 
I believe that the problem isn't the 'Undesired empty line', that line is there because of the carriage return\line feed (\r\n) of the previous line, deleting the last line doesn't remove those from the previous line. Try deleting the cr/lf from the previous line.

Also, I have noticed that with TMemo if I first do SetTextBuf, then add lines, that the cr/lf isn't there on the last line added. Not sure why -- but like this:

Code:
 Memo2->SetTextBuf(&quot;Line 1&quot;);
Memo2->Lines->Add(&quot;Line 2&quot;);
Memo2->Lines->Add(&quot;Line 3&quot;);

Good Luck.
 
It worked.
What is SetTextBuf and what does it do?
If I run it and enter &quot;&quot; as the value then it when i use the Add command it still adds the empty line.

Thanks,
Ruggie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top