比方说程序中有AB2个Button按钮,当按A按钮时候Memo第一项显示1按B按钮时候第二项显示2或者我按A按钮时候1可以在Memo中任何一项显示比方说在100项显示,这样怎么做?

解决方案 »

  1.   

    不太懂你的意思,不知道你是不是这个意思,获取某行的内容
    memo1.Lines[memo1.CaretPos.Y];
      

  2.   

    有2个Button按钮,按Button1时候Memo第一行是1,按Button2的时候内容显示在第2行。这样怎么做?
      

  3.   

    还是不太明白,按Button2的时候内容显示在第2行,第2行什么,内容还是显示1
    button1click
    var
    olditem:string;//全局变量
    oldindex:integer;
    begin
    oldindex:=0;
    olditem:=memo1.lines[0];
    memo1.lines[0]:='1';button2click不懂你的意思,如果也是显示1的话那么memo1.lines[oldindex]:=olditem;
    olditem:=memo1.lines[1];
    oldindex:=1;
    memo1.lines[1]:='1';
      

  4.   

    明白你的意思了,是要在memo里的行成选中状态对吧?
    是不是要这样
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    Memo1.SetFocus ;
    Memo1.SelStart:=0;
    Memo1.SelLength:=length(self.Memo1.Lines[0])
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
    Memo1.SetFocus ;
    Memo1.SelStart:=length(self.Memo1.Lines[0])+2;
    Memo1.SelLength:=length(self.Memo1.Lines[1]);
    end;
      

  5.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    Memo1.Lines[0]:= '今天是:'+ FormatDateTime('yyyy-mm-dd',now);
    Memo1.Lines[1]:= '现在时间为:'+ FormatDateTime('hh:mm:ss',now);
    end;我的意思是:按Button1的时候Memo1第0行内容出来了,但是没第一行内容。或者Memo1.Lines[10]我让它出现在第10行应该怎么做?