Wrox Programmer Forums
|
BOOK: Visual Basic 2005 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2005 Programmer's Reference by Rod Stephens; ISBN: 9780764571985
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2005 Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 5th, 2006, 03:20 AM
Registered User
 
Join Date: May 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default HScroll Bar for List box

Hi,
  I have a list box,items are added dynamically, the Horizontal scroll bar is added below the list box. I want use this Horizontal scroll bar when ever the item length goes out of list box scope for viewing the full item.

  Regards,
  Ravi.B

 
Old May 9th, 2006, 09:00 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Set the ListBox's HorizontalScrollbar to True. I found that at least some times the control doesn't leave quite enough room for the longest item. If you add a couple of spaces at the end of the longest item (or every item), it works fine.

If you only want it when necessary, loop through the items in the list. Use CreateGraphics to get a Graphcis object for the ListBox and use its MeasureString method to see how wide the strings are. Compare them to the control's width (minus a little room for the control's borders). Then set the property accordingly.


Rod
RodStephens@vb-helper.com
Author of "Visual Basic 2005 Programmer's Reference"
http://www.vb-helper.com/vb_prog_ref.htm
 
Old May 9th, 2006, 10:09 PM
Registered User
 
Join Date: May 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you Rod for replying,
  I am using VB6, there is no HorizontalScrollbar present in property to make it True.

  Is there any alternative for that problem..?

Thank,
Ravi B


 
Old May 10th, 2006, 07:23 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Ah ha! Take a look at these examples:

    http://www.vb-helper.com/howto_listbox_hscroll.html
    http://www.vb-helper.com/howto_listb...scrollbar.html


Rod
RodStephens@vb-helper.com
Author of "Visual Basic 2005 Programmer's Reference"
http://www.vb-helper.com/vb_prog_ref.htm
 
Old May 14th, 2006, 10:34 PM
Registered User
 
Join Date: May 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you.. i got it..


Quote:
quote:Originally posted by Rod Stephens
 Ah ha! Take a look at these examples:

    http://www.vb-helper.com/howto_listbox_hscroll.html
    http://www.vb-helper.com/howto_listb...scrollbar.html


Rod
RodStephens@vb-helper.com
Author of "Visual Basic 2005 Programmer's Reference"
http://www.vb-helper.com/vb_prog_ref.htm





Similar Threads
Thread Thread Starter Forum Replies Last Post
Add a Horizontal Scroll Bar to a List Box in VBA hewstone999 Access VBA 1 February 28th, 2008 08:31 AM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
select box/List box alphabetic sort sasidhar79 Javascript How-To 3 November 10th, 2004 03:04 AM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.