while not adoTable3.Eof do begin
    if s<>adoTable3.FieldByName('编号').asstring then begin
      s:=adotable3.FieldByName('编号').asstring;
      s1:=adotable3.FieldByName('是否发送').asstring;
      if s1='是' then begin
      listbox1.Items.Add(s);
      在这里添加代码使添加的s字体变为绿色      
      end
      else
      begin
      listbox1.Items.Add(s);
      在这里添加代码使添加的s字体变为红色;
      end;
      end;
    adoTable3.Next;
  end;  

解决方案 »

  1.   

    你可以在listbox的canvas上画出来,估计你是不干了,你可以用richedit,那个可以控制每个字的颜色
      

  2.   

     procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    begin
      with (Control as TListBox) do
      begin
        if Items[Index]='是' then
        Canvas.Font.Color:=clGreen;
        Canvas.TextOut(Rect.Left,Rect.Top,Items[Index]);
      end;end;procedure TForm1.btn1Click(Sender: TObject);
    begin
      ListBox1.Items.Add('123434');
      ListBox1.Items.Add('是');
    end;
      

  3.   

    记得将TListBox.Stype设置为lbOwnerDrawFixed
      

  4.   

    不成啊,我要的是根据数据库里的数据判断而不是根据listbox内容判断啊
      

  5.   

    你原来是怎么从ADO控件中添加数据到TListBox中就怎么添加,就你你贴出来的代码那样就行了,
    只要在TListBox中加上像我上面写的那样自绘处理代码就行了,
    当你添加字条串时TListBox控件就会进行重绘,重绘是会调用你写的OnDrawItem事件的代码。
      

  6.   

    谢谢大家了
    我用RichEdit了