Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If the fancy scroll bar can be implemented as another control (your image actually looks like that), here is the code of a ListBox that supports custom scrolling:</p> <pre><code>Imports System.Runtime.InteropServices Public Class CustomScrollListBox Inherits ListBox Public Sub Scroll(ByVal percentage As Single) If (percentage &lt; 0.0!) Then Throw New ArgumentException(Nothing, "percentage") End If ' Sends the scroll / set position Windows message Const WM_VSCROLL As Integer = &amp;H115 Const SB_THUMBPOSITION As Integer = 4 Dim wp As Integer = CInt(((percentage * MyBase.Items.Count) * 65536.0!)) + SB_THUMBPOSITION CustomScrollListBox.SendMessage(MyBase.Handle, WM_VSCROLL, New IntPtr(wp), IntPtr.Zero) End Sub &lt;DllImport("user32.dll")&gt; _ Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr End Function Protected Overrides ReadOnly Property CreateParams() As CreateParams Get ' Removes the vertical scroll window style Dim p As CreateParams = MyBase.CreateParams Const WS_VSCROLL As Integer = &amp;H200000 p.Style = (p.Style And -WS_VSCROLL) Return p End Get End Property End Class </code></pre> <p>And here is a sample form that uses it. I have implemented the custom scroller as a standard Trackbar (trackBar1) for the example:</p> <pre><code>Public Class Form1 Private trackBar As TrackBar Private listBox As CustomScrollListBox Protected Overrides Sub OnLoad(ByVal e As System.EventArgs) ' initialize some listbox props listBox = New CustomScrollListBox listBox.Location = New Point(&amp;H19, 210) listBox.Name = "listBox2" listBox.Size = New Size((&amp;H17D - Me.TrackBar1.Width), &amp;HAD) listBox.TabIndex = 1 MyBase.Controls.Add(listBox) ' add some items Dim i As Integer For i = 0 To 100 - 1 listBox.Items.Add(("item" &amp; i)) Next i End Sub Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll ' compute trackbar's position as a percentage listBox.Scroll(CSng(TrackBar1.Maximum - TrackBar1.Value) / TrackBar1.Maximum - TrackBar1.Minimum) End Sub End Class </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload