2行表示のリストを作成するには、OnDrawItem イベントと OnMeasureItem イベントを使用します。
以下のステップで行います。
この方法は、TCheckListBox でも使用できます。(2行目が固定で“2行目”になっているので、お好みに合わせて変更してください。 また、Styleを「lbOwnerDrawVariable」に変更するのを忘れないでください。)
procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer; var Height: Integer); begin Height := -1 * TListBox(Control).Font.Height * 2 + 6; // リストボックスの1項目の高さを設定 end; procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); begin with TListBox(Control) do begin Canvas.FillRect(Rect); Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, Items[Index]); // 1行目 Canvas.TextOut(Rect.Left + 2, Rect.Top + (-1 * Font.Height) + 4, '2行目'); // 2行目 end; end;
コメント (0件)