-3

could someone help me hide the vertical scrollbar of a listbox.

I am using visual studio 2012 and i'm coding in vb

IeuanW
  • 228
  • 1
  • 9
  • 25
  • 1
    Are you planning on having SO complete your project assignment for you? – OneFineDay May 28 '15 at 02:37
  • Assuming you are talking about removing it when it appears as a result of items being added, you could respond to the ClientSized changed event and then use PInvoke to remove it. [Similar code here](http://stackoverflow.com/a/24722635/1070452) – Ňɏssa Pøngjǣrdenlarp May 28 '15 at 03:06

1 Answers1

0

How about the use of some API calls?

Please check out this link to see how to implement...

http://www.xtremevbtalk.com/archive/index.php/t-270345.html

 Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As IntPtr) As Int32
 Private Declare Function ShowScrollBar Lib "user32" (ByVal hwnd As IntPtr, ByVal wBar As Int32, ByVal bShow As Int32) As Int32

 Private Const SB_VERT = 1


 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  ShowScrollBar(ListBox1.Handle, SB_VERT, False)
 End Sub

 'scroll down
 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  LockWindowUpdate(ListBox1.Handle)
  ListBox1.TopIndex = ListBox1.TopIndex + 1
  ShowScrollBar(ListBox1.Handle, SB_VERT, False)
  LockWindowUpdate(0&)
 End Sub

 'scroll up
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
 LockWindowUpdate(ListBox1.Handle)
 ListBox1.TopIndex = ListBox1.TopIndex - 1
 ShowScrollBar(ListBox1.Handle, SB_VERT, False)
 LockWindowUpdate(0&)
End Sub
Trevor
  • 7,777
  • 6
  • 31
  • 50