listbox1MeasureItem是定制Item的高度~~
ListBox1DrawItem()是自己画Item~~

解决方案 »

  1.   

    procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer; var Height: Integer);var
    Bitmap: TBitmap;
    begin
    with Control as TListBox do
    begin
    Bitmap := TBitmap(Items.Objects[Index]);
    if Bitmap <> nil then
    if Bitmap.Height > Height then Height := Bitmap.Height;
    end;
    end;
      

  2.   

    procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;Rect:TRect;State: TOwnerDrawState);
    var
    Bitmap: TBitmap;      { temporary variable for the item抯 bitmap }
    Offset: Integer;      { text offset width }
    begin
    with (Control as TListBox).Canvas do  { draw on control canvas, not on the form }
    begin
    FillRect(Rect);       { clear the rectangle }
    Offset := 2;          { provide default offset }
    Bitmap := TBitmap((Control as TListBox).Items.Objects[Index]);  { get the bitmap }if Bitmap <> nil then
    begin
    BrushCopy(Bounds(Rect.Left + 2, Rect.Top, Bitmap.Width, Bitmap.Height),
    Bitmap, Bounds(0, 0, Bitmap.Width, Bitmap.Height), clRed);  {render bitmap}
    Offset := Bitmap.width + 6;    { add four pixels between bitmap and text}
    end;
    TextOut(Rect.Left + Offset, Rect.Top, (Control as TListBox).Items[Index])  { display the text }
    end;
    end;