我修改了ListBox的字号,设为了12号,默认是8号,
可是第一行永远是8号字体,而后面的是变成了12号,
请问高手,这是啥原因?怎么解决?

解决方案 »

  1.   

    listbox的style属性是什么?是不是设成lbOwnerDrawVariable了,而且在listbox的OnDrawItem事件里写什么代码了?
      

  2.   

    没有是,style是lbStandard,没有去重绘呀,我倒想将它重绘了,可是不知道改怎么做
      

  3.   

    重新放一個LISTBOX到窗體試下看會不會這樣。本身LISTBOX裏面的列都是靠 TStringList  去維護的,沒理由在非自繪的情況下不同的。
      

  4.   

    procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    begin
      if state = [odSelected,odFocused ]then
      begin
        ListBox1.Canvas.Brush.Color := clBlue;
        ListBox1.Canvas.FillRect(Rect);
        ListBox1.Canvas.Font.Size := 10;
        ListBox1.Canvas.Font.Color := clBlack;
        ListBox1.Canvas.TextOut(rect.Left,rect.Top,ListBox1.Items[Index]);
      end else begin
        ListBox1.Canvas.Brush.Color := clWhite;
        ListBox1.Canvas.FillRect(Rect);
        ListBox1.Canvas.Font.Size := 10;
        ListBox1.Canvas.TextOut(rect.Left,rect.Top,ListBox1.Items[Index]);
      end;end;  隨便寫了自繪的代碼,根據需要你再改改。  STYLE 設為: lbOwnerDrawVariable