VB ListBox Add horizontal scroll bar

Source: Internet
Author: User

Private Declare FunctionSendMessageLib "User32" Alias "SendMessageA"(ByValhwnd as Long, _ByValWmsg as Long, _ByValWParam as Long, _lparam asAny) as LongPrivate ConstLb_sethorizontalextent = &H194
--------------------------------------------------------------------------------------------------Private Subsetlistwidth ()'If the list box is not wide enough, increase the horizontal scroll bar DimI as Integer DimList_maxl as Integer 'get the maximum length of the option content fori =0 toList1.listcount-1 '' Keep the longest string in List_maxl If Len(List1.list (i)) > List_maxl ThenList_maxl=Len(List1.list (i)) +2 End If NextI'determines if the content is not displayed completely, and if yes, adds a horizontal scroll bar If Me. TextWidth ("AA") * LIST_MAXL > List1.width ThenSendMessage List1.hwnd, Lb_sethorizontalextent,Me. TextWidth ("a") * List_maxl,ByVal 0&End IfEnd Sub
--------------------------------------------------------------------------------------------------
Private SubForm_Load ()DimI as Integer      'to add an option to a ListBox control       fori =0  to  -List1.AddItem ("this is, according to JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ: (The first"+CStr(i)) &"line)"           'List1.AddItem ("(CStr (i)) &" line) "      NextI'set the form coordinate scale mode and font size      Me. ScaleMode =VbpixelsMe. FontSize =list1.fontsize Setting the horizontal scroll bar of a list boxPagerSetlistwidthEnd Sub

VB ListBox Add horizontal scroll bar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.