Subject Re: TEditEnh component selstart and sellength
Author Zoltan Hubai
Hi Geoff!

Thanks for answering. I tryd both options but without success. With the
second option I got the right selstart but when I try to set it dont work.

What I try to do in my application is somthing like:

procedure TForm1.Edit1OnChange(Sender: TObject);
var
OldSelStart: integer;
begin
// Check if the new text value differs from the last
if (TEdit(Sender).Text <> FOldValue) and
(Pos(TEdit(Sender).Text,FOldValue) <> 1) then begin
// Save the SelStart value
OldSelStart := TEdit(Sender).SelStart;
..... Here I check if the new value is in the list of the possible
values
if InList then begin
FOldValue := TEdit(Sender).Text;
TEdit(Sender).OnChange := nil;
TEdit(Sender).Text := newvalue from the list...
TEdit(Sender).SelStart := OldSelStart;
TEdit(Sender).SelLength := Length(newvalue) - OldSelStart;
TEdit(Sender).OnChange := Edit1OnChange;
end
else
FOldValue := TEdit(Sender).Text;
end;
end;


Zoltan