Hi, I use RichEdit in Delphi 11 but cannot replace a word. SelText always finds the characters in the next line

67 Views Asked by At

RichEdit always selects text in next line, replacing the incorrect values. Marker is a string constant = '/~^&"£$'

Assert ( Pos ( marker, RichEdit1.Lines.Text ) = 0 );  // This confirms that there is no marker
RichEdit1.Lines[idx] := Marker +  RichEdit1.Lines[idx]; // First put a marker at beginning of line
MarkerPos1 := Pos ( Marker, RichEdit1.Lines.text ) - 1; // Find the marker
RichEdit1.SetFocus;
RichEdit1.SelStart := Pos ( Marker, RichEdit1.Lines.Text ) - 1; // Now find position of marker => line beginning
RichEdit1.SelLength := Length (  RichEdit1.Lines[idx] );
tmpLine := RichEdit1.SelText;
FontSize := RichEdit1.SelAttributes.Size;                // Get the fontsize

TmpLine does not contain the text in RichEdit1.Lines[idx], but the text in the following line.

Some assistance will be appreciated

0

There are 0 best solutions below