Board index » delphi » Horizontal Scrollbar on TListBox

Horizontal Scrollbar on TListBox

Hello everyone,

 This has to be an obvious one. How do I get an horizontal scrollbar on a
TListBox? Can't fugure it out...

Regards,
P      

 

Re:Horizontal Scrollbar on TListBox


Quote
Patrick Drouin wrote:

> Hello everyone,

>  This has to be an obvious one. How do I get an horizontal scrollbar on a
> TListBox? Can't fugure it out...

How bout' this:

procedure Form1.FormActivate(Sender : tObject);
begin
  SendMessage(ListBox1.Handle, LB_SetHorizontalExtent, 1000,
longint(0));
end;

Rkr
--
                   \|||/
                   /'^'\
                  ( 0 0 )
--------------oOOO--(_)--OOOo--------------
. Reid Roman                              .
. Delphi Programmer / Analyst             .
. TVisualBasic:=class(None)               .
. May the Source be With You              .
-------------------------------------------
. Auto-By-Tel (http://www.autobytel.com)  .
. Irvine, CA U.S.A                        .
. E-Mail : rkroman (at) pacbell (dot) net .
. or reidr (at) autobytel (dot) com       .
-------------------------------------------

Re:Horizontal Scrollbar on TListBox


Here's a slightly different approach that triggers the scrollbars
based on the size of the contents of the listbox:

{the following code provides for horizontal scrollbars in OrgListBox}
  MaxWidth := 0;
  for i := 0 to OrgListBox.Items.Count -1 do
    if MaxWidth <
OrgListBox.Canvas.TextWidth(OrgListBox.Items.Strings[i]) then
      MaxWidth :=
OrgListBox.Canvas.TextWidth(OrgListBox.Items.Strings[i]);
  SendMessage(OrgListBox.Handle,LB_SETHORIZONTALEXTENT, MaxWidth+2,0);

Other Threads