When code gives the focus to a TEdit that contains some text .. lazarus / 31-LCL ---------------------------------------------------------------------- Elmug · 2011-08-17 11:15 Good people, When a short procedure completes giving the focus to a Tedit box which already contains some text, the text appears SHADED or highlighted, meaning that it is selected. Now, at this point the TEdit is ready to take characters from the keyboard. However, the first character that is typed WIPES out the existing text, and then that first character typed appears, and it is NOT highlighted, so more characters can be typed. So, how to pass the focus to that TBox WITHOUT the text appear selected, so that the next char typed only ADDS to the existitng text? I suppose it'd be a command like "unselect" the Text so it is right then unselected? Thanks! ---------------------------------------------------------------------- Zoran · 2011-08-17 11:24 Edit1.SetFocus;   Edit1.SelLength := 0; ---------------------------------------------------------------------- Elmug · 2011-08-17 12:26 Quote from: Zoran on August 17, 2011, 01:24:18 pm  Edit1.SetFocus;   Edit1.SelLength := 0; Thank you, Zoran. This gives me an unselected text, except that the next char one types is added to the left. What you code is fine, but if only the cursor were at the end of the string. Now, I tried using the Length function, which figures the length of the string in the box, and put that instead of the zero. Yes, the cursor is now at the end, but the next char I type DELETES THE entire string. In other words, with the Length functin applied, I am back to the original question. Any suggestions? Thanks! ---------------------------------------------------------------------- Zoran · 2011-08-17 12:44 Quote from: Elmug on August 17, 2011, 02:26:01 pmWhat you code is fine, but if only the cursor were at the end of the string.   Edit1.SetFocus;   Edit1.SelStart := Length(Edit1.Text);   Edit1.SelLength := 0; ---------------------------------------------------------------------- Elmug · 2011-08-17 13:08 Quote from: Zoran on August 17, 2011, 02:44:39 pmQuote from: Elmug on August 17, 2011, 02:26:01 pmWhat you code is fine, but if only the cursor were at the end of the string.   Edit1.SetFocus;   Edit1.SelStart := Length(Edit1.Text);   Edit1.SelLength := 0; Hi Zoran, to let you know that this above code worked EXACTLY as needed and I had been trying to solve this for the last 3 weeks or so. So, I will put it my treasure box! ---------------------------------------------------------------------- evoshroom · 2012-05-19 23:49 I had this exactly same problem except the code provided didn't work.  Is there a bug or anything else that should be considered? Code upon hitting enter in another edit on Form4: Form4.Hide; Form1.Edit1.SetFocus; Form1.Edit1.SelStart := Length(Form1.Edit1.Text); Form1.Edit1.SelLength := 0;  After executed all of the text in Form1.Edit1 remains selected. ---------------------------------------------------------------------- Bart · 2012-05-21 09:46 TEdit has a property AutoSelect. When set to False, it should not select text when the control gets focus. Bart