Board index » delphi » Horizontal scroll bar

Horizontal scroll bar

Hi all,
    Is it possible to have a horizontal scroll bar in TCheckListBox ?
    How can it be done ?
    Thanks in advance.

--

Regards,
SHOO.

 

Re:Horizontal scroll bar


Quote
In article <7k4fip$j3...@forums.borland.com>, Shoo wrote:
> Is it possible to have a horizontal scroll bar in TCheckListBox ?
>     How can it be done ?

Since the control derives from TCustomlistbox it can be done the same
way as for a normal listbox: send a LB_SETHORIZONTALEXTENT message to
the control.

<quote>
 Making horizontal scrollbar appear in listbox

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 );
</quote>

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads