在做MIS开发时,遇到这样一个问题。
我是用ListBox来显示提示的信息的,现在我想实现这样的效果
如果是出错的提示信息,用红色或者其他的颜色来显示提示的内容,与一般的提示信息区分开来。
请求支招!不胜感谢。

解决方案 »

  1.   

    在OnDrawItem事件上色
    具体代码查帮助
      

  2.   

    楼上正解了。procedure TForm1.FormCreate(Sender: TObject);
    begin
      ListBox1.Style:=lbOwnerDrawVariable;
    end;procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    begin
      if ListBox1.Items[Index]='abc' then
        ListBox1.Canvas.Brush.Color:=clBlue
      else
        ListBox1.Canvas.Brush.Color:=clYellow;
      ListBox1.Canvas.FillRect(Rect);
      ListBox1.Canvas.TextOut(Rect.Left, Rect.Top, ListBox1.Items[Index]);
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      ListBox1.Items.Add('abc');
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      ListBox1.Items.Add('123');
    end;
      

  3.   

    DELPHI 帮助是很有用的东西! 楼主要多用HELP~!