richedit有两列数据,现在想以第一列的数据为搜索依据,同时输出第二列数据该如何做?
数据格式如下:
5 4
1 1
3 5            假如我现在搜索第一列的134会得到第二列的159就是这么回事
4 9 
7 3      

解决方案 »

  1.   

    你这些问题都是同样的道理,循环搜索procedure TForm1.Button3Click(Sender: TObject);
    var
      i,j,m:Integer;
      s,s1:string;
      str:TStrings;
    begin  i:=self.RichEdit1.Lines.Count;
      if i=0 then
        Exit;
      str:=TStringList.Create;
      str.Clear;
      self.RichEdit2.Lines.Clear;
      for j:=0 to i-1 do
      begin
        s:=self.RichEdit1.Lines.Strings[j];
        str.Clear;
        ExtractStrings([' '],[],PChar(s),str);
        m:=str.Count;
        if m<2 then
          Continue;
        s:=str.Strings[0];
        s1:=str.Strings[1];
        if (s='1') or (s='3') or (s='4') then
          self.RichEdit2.Lines.Add(s1);
      end;
    end;
      

  2.   

    我的希望是用findtext查找,但是我写的是查找一行的,所以刚才的那个帖子就是要先进行分列然后再查找,但是觉得有些麻烦,所以还请哪位指教一下简单的搜索方法
      

  3.   

    不是很明白,findtext直接调用就行啊
      

  4.   

    把richedit中内容,行列互换一下,然后再findtext
      

  5.   

    1 用=替换 richedit 中内容 中空格
    2 用一个 TstringList 变量 转载 richedit 中内容
    然后 用 Name 和Value 的关系  直接对应出来