var
editform:Teditform;
a:boolean;
procedure TEditForm.FormShow(Sender: TObject);
begin
a:=true;
end;
procedure TEditForm.FormPaint(Sender: TObject);
begin
if a then
begin
COMBOBOX1.SetFocus;
cOMBOBOX1.SelStart := 2;
COMBOBOX1.SelLength :=0;
a := false;
end;
end;
写在这里也可以
procedure TForm1.FormPaint(Sender: TObject);
var str:string;
begin
if combobox1.Focused then
begin
str:=combobox1.text;
combobox1.text:='';
combobox1.text:=str;
ComboBox1.SelStart := pos('光',ComboBox1.text)+2 ;
end;
end;
procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var str:string;
begin
if combobox1.Focused then
begin
str:=combobox1.text;
combobox1.text:='';
combobox1.text:=str;
ComboBox1.SelStart := pos('光',ComboBox1.text)+2 ;
end;