selected in TEdit

How can i test to see if something is selected (highlighted) in a TEdit ?  I am using a TEdit for numbers only
ChLaAsked:
Who is Participating?
 
B-o-l-dConnect With a Mentor Commented:
hi chla,

you could test the member function SelLength. if you find something different than 0, you have selected text:

if myEdit.SelLength > 0 then begin
   DoSomething;
end;

refer also to SelStart and SelectAll.

cheers,
bold
0
 
ChLaAuthor Commented:
That should work. i will test it tomorrow and let you know. Thank you.

I had found SelectAll. What is SelStart ? Why are none of these things explained in the help files ?
0
 
Sinisa VukCommented:
SelectAll is for highlight all text in edit and SelStart is similar to SelLength, it is greater than zero if you select some text in edit and represents start where selecting begins. It is in chars units. Some text is highlighted form SelStart and is long as SelLength.
0
 
B-o-l-dCommented:
just to clarify:

SelectAll is a command (procedure/function) to select the whole text in the edit.

SelStart / SelLength are properties to read or write to look, whats selected or to set a selection. hereby points SelStart to the first character in the edit component, that is selected and SelLength tells you how many characters are selected.

copy(MyEdit.Text, MyEdit.SelStart, MyEdit.SelLength) gives you exactly the selected text from a edit box.

cheers,
bold
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.