Board index » cppbuilder » Text changes not appearing in TMemo

Text changes not appearing in TMemo

As part of a project to fix up errors in text files created by OCRing
images, I paste text into a TMemo, then click repetitively on 2
TButtons, one of which finds the next error and the other automatically
fixes it.

I know, by using the de{*word*81}, that this code is actually executing.
However I can't get the changes to show up in the TMemo on the screen -
although I CAN type changes into it.

I must be making some really simple mistake - could somebody please
tell me what's wrong with this code? (relevant excerpt pasted below)

//  This part changes the space between 2 uppercase alphas into an
underscore

int SpaceAt = -1;

void __fastcall TForm1::NextSpaceButtonClick(TObject *Sender)
{
  TButton* Clickee = (TButton*) Sender;
  // This block of code executes, but change doesn't show up in Memo1

  if (Clickee == UnderscoreButton && SpaceAt > 0)
  {
    Memo1->Text[SpaceAt] = '_';
    SpaceAt = -1;
  }
  .......

Quote
}

Thanks for reading,
Adrian Carter

Sent via Deja.com http://www.deja.com/
Before you buy.

 

Re:Text changes not appearing in TMemo


It's ok, I've got it figured out.
This is just the way TMemo works.

You have to reassign the whole of the Text property,
eg TMemo1->Text = whatever, for the changes to be visible.
You can't just change individual characters of Text by
using the [] operator.

Can't say I like it though.

Adrian Carter

Sent via Deja.com http://www.deja.com/
Before you buy.

Other Threads