Board index » delphi » Horizontal scroll bar in list box

Horizontal scroll bar in list box

How can I add a horizontal scroll bar to a list box to allow the user to
see all of a line that is wider than the list box?

Thanks,
Jon

 

Re:Horizontal scroll bar in list box


Jon,

send a LB_SETHORIZONTALEXTENT message to the listbox, that makes the
horizontal scrollbar appear automatically if the extent is larger than the
listbox width.

You can calculate the necessary width from the strings in the listbox this
way (code is assumed to sit in a form method):

  canvas.font := listbox.font;
  maxlen := 0;
  for i:= 0 To listbox.items.count-1 do begin
    len:= canvas.textwidth( listbox.items[i] );
    If len > maxlen then
      maxlen := len;
  end;
  canvas.font := font;
  listbox.Perform( LB_SETHORIZONTALEXTENT, maxlen, 0 );

Peter Below (TeamB)  100113.1...@compuserve.com)

Quote
In article <348390F0.FA5B2...@gte.net>, Jon Jacobs wrote:
> From: Jon Jacobs <jqjac...@gte.net>
> Newsgroups: borland.public.delphi.vcl.components.using
> Subject: Horizontal scroll bar in list box
> Date: Mon, 01 Dec 1997 22:39:13 -0600

> How can I add a horizontal scroll bar to a list box to allow the user to
> see all of a line that is wider than the list box?

> Thanks,
> Jon

Re:Horizontal scroll bar in list box


Quote
> send a LB_SETHORIZONTALEXTENT message to the listbox, that makes the
> horizontal scrollbar appear automatically if the extent is larger than the
> listbox width.

Thank you very much,
Jon

Other Threads