我想改变headercontrol的sections里面文字的颜色,怎么办?

解决方案 »

  1.   

    object HeaderControl1: THeaderControl
      Sections = <
        item
          ImageIndex = -1
          Style = hsOwnerDraw
        end
      >
      OnDrawSection = HeaderControl1DrawSection
    end
    procedure TForm1.HeaderControl1DrawSection(HeaderControl: THeaderControl;
      Section: THeaderSection; const Rect: TRect; Pressed: Boolean);
    var
      vRect: TRect;
    begin
      vRect := Rect;
      HeaderControl.Canvas.Font.Color := clRed;  DrawText(HeaderControl.Canvas.Handle, PChar(Section.Text),
        Length(Section.Text), vRect, DT_CENTER or DT_VCENTER or DT_SINGLELINE);
    end;
      

  2.   

    我注意到您是想用hsownerdraw的办法重画,但是有没有办法在hstext的情况下来改变字体颜色呢?