通过pos在你的字符串里面查找~~“,”号作为分割符~~
然后把找到的数据与数据库里面的ID字段的内容进行比较~~如果存在~~
则选中~~也就是打一个“√”号~~

解决方案 »

  1.   

    这个我知道问题是我用什么控件好呢??
    有时候可能有好多的记录..我想能像dbgrid一样可以有滚动条来显示??
      

  2.   

    可以用CheckListBox1,先从库里提取记录,如有,则加上,如存在,则选中
    ~~也就是另CheckListBox1.Checked[i] := True;
    for example: (你再作一些其他处理)With arid do
      begin
        if Active then
        begin
          Filtered := false;
          First;
          While Not Eof do
          begin
            CheckListBox1.Items.Add(FieldByName('name').AsString);
            CheckListBox1.Checked[CheckListBox1.Items.Count - 1] := True;
            Next;
          end;
        end;
      end;
      

  3.   

    再给你一个function,他将你的长字符串以“,”号作为分割符
    (分割符在function中可设置)转换成TString,这样好操作。
    procedure StringToStrings(S: string; const Strings: TStrings;
    Delimiter: char = ',');
    var
    P: integer; //the pos that delimiter is in S
    begin
    with Strings do
      begin
       Clear;
        P := Length(s);
        while P>0 do
        begin
    P := Pos(Delimiter,S);  
          if P=0 then
          begin //the last substring
           Add(S);
            Break;
          end;
          Add(Copy(S, 1, P-1));
          S := Copy(S, P+1, Length(S));
    end; //while
      end; //with
    end;
      

  4.   

    直接读到listbox里就可以了,它默认就是用","做分割符.