S
sy0116
Unregistered / Unconfirmed
GUEST, unregistred user!
我想编程实现当双击Memo3的某一行时选中Memo1控件中的某一行,Memo3中的格式是这样的:
XXX[ABCD]QWERT
上面的XXX是数字,代表要选中的memo1中的行号,我现在是用以下代码,发现没用:
procedure TForm1.Memo3DblClick(Sender: TObject);
var
CurrentLine:string;
Line:Integer;
begin
CurrentLine := Memo3.Lines[Memo3.CaretPos.Y];
Line := StrToInt(Copy(CurrentLine,0,Pos('[',CurrentLine) - 1));//取得XXX所对应的数字,即行号
Memo1.SelStart := Pos(Memo1.Lines[Line],Memo1.Lines.Text) - 1;
Memo1.SelLength := Length(Memo1.Lines[Line]);
//SendMessage(Memo1.Handle,EM_SETSEL,Memo1.SelStart,Memo1.SelLength + Memo1.SelStart);
//ShowMessage(IntToStr(Memo1.SelLength));
end;
XXX[ABCD]QWERT
上面的XXX是数字,代表要选中的memo1中的行号,我现在是用以下代码,发现没用:
procedure TForm1.Memo3DblClick(Sender: TObject);
var
CurrentLine:string;
Line:Integer;
begin
CurrentLine := Memo3.Lines[Memo3.CaretPos.Y];
Line := StrToInt(Copy(CurrentLine,0,Pos('[',CurrentLine) - 1));//取得XXX所对应的数字,即行号
Memo1.SelStart := Pos(Memo1.Lines[Line],Memo1.Lines.Text) - 1;
Memo1.SelLength := Length(Memo1.Lines[Line]);
//SendMessage(Memo1.Handle,EM_SETSEL,Memo1.SelStart,Memo1.SelLength + Memo1.SelStart);
//ShowMessage(IntToStr(Memo1.SelLength));
end;