Recent

Author Topic: Can CheckListBox wrap a long text?  (Read 6272 times)

asdf

  • Sr. Member
  • ****
  • Posts: 310
Can CheckListBox wrap a long text?
« on: November 27, 2010, 10:08:17 am »
I have a CheckListBox but it's width is too narrow to display some long lines of text.
So, the end of such text is out of the box.
« Last Edit: November 27, 2010, 11:33:38 am by asdf »
Lazarus 1.2.4 / Win 32 / THAILAND

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: Can CheckListBox wrap a long text?
« Reply #1 on: December 10, 2010, 09:01:02 pm »
 ;D
Lazarus 1.2.4 / Win 32 / THAILAND

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: Can CheckListBox wrap a long text?
« Reply #2 on: December 11, 2010, 10:20:23 pm »
if you're in a hurry, set the caption to empty string and add a label component to the right.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Can CheckListBox wrap a long text?
« Reply #3 on: December 12, 2010, 03:18:18 am »
if you're in a hurry, set the caption to empty string and add a label component to the right.

Doesn't that kind of defeat the whole purpose of a _scrolling_ list box?

I can't think of any solution offhand other than intercepting the event when an item is checked and displaying its full text in a TLabel below the list box. Of course the user would likely want to see the full item before checking it...

Thanks.

-Phil

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: Can CheckListBox wrap a long text?
« Reply #4 on: December 12, 2010, 07:59:49 am »
If I use this technique ..

procedure TForm1.CheckListBox1MouseEnter(Sender: TObject);
begin
  CheckListBox1.ShowHint:=true;
  if the mouse cursor is on an item(either is checked true or false) and with no clicking.
  CheckListBox1.Hint:=Text of such item;
end;     

Please help writing codes for above 2 red-colored lines. 
                                     
Lazarus 1.2.4 / Win 32 / THAILAND

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: Can CheckListBox wrap a long text?
« Reply #5 on: December 12, 2010, 09:02:14 pm »
Code: Pascal  [Select][+][-]
  1. procedure TForm1.CheckListBox1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  2. var i: integer;
  3. begin
  4.   i := CheckListBox1.ItemAtPos(Point(X,Y), true);
  5.   if i = -1 then Exit;
  6.   CheckListBox1.Hint := CheckListBox1.Items[i];
  7.   if i <> HintLastIndex then begin
  8.     Application.ActivateHint(CheckListBox1.ClientToScreen(Point(X,Y)));
  9.     HintLastIndex := i;  // prevents flicker
  10.   end;
  11. end;
  12.  
  13.  

could use a bit of tweaking. HintLastIndex is a global var or form field (set to -2 at start, mossibly on mouseleave as well)

 

TinyPortal © 2005-2018