如何设置image控件背景颜色

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      Image1.Canvas.Brush.Color:=clYellow;
      Image1.Canvas.FillRect(Rect(0,0,Image1.Width,Image1.Height));
    end;
      

  2.   

    楼上的正解:我在来一段
    with Image1.canvas do
      begin
        Brush.Color := clBlack;
        FillRect(Bounds(0, 0, Image1.Width, Image1.Height));
        //画线颜色
         Pen.Color := clYellow;
        Pen.Width := 1;
        //画横线
        for i := 0 to 6 do
        begin
          MoveTo(2, 30 + i * 23);
          LineTo(463, 30 + i * 23);
        end;
        //画竖线
        for i := 0 to 2 do
        begin
          DrawLine(154 * i + 2);
        end;
    end;