Author: Tomas Rutkauskas
The goal is to insert a string into the text in a TComboBox at the last cursor
position. An assignment like edInput.SelText := newText; works fine with a TEdit
when AutoSelect = false, but not with combobox. SelStart always returns 0 after
exiting. So no matter where the user had the cursor, the text is always inserted at
the front. Is there a quick workaround for this?
Assign the Combobox.selstart value to a variable on the KeyUp event of the combobox
and call the variable when you need the position. You can take the hint as a
variable or declare your own variable.
1 2 procedure TForm1.ComboBox1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
3 begin4 ComboBox1.hint := inttostr(Combobox1.selstart);