AdvancedHMI Software
General Category => Open Discussion => Topic started by: robkwan on March 02, 2016, 02:06:33 PM
-
I need to increase the listview control's vertical scrollbar width to be useable on a touch panel without using a stylus. I am trying to avoid using 2 buttons (up/down) to simulate the scrollbar.
Any suggestion?
-
One method is to add a VScrollBar (from the ToolBox) next to the ListBox, then use this code to have it control the listbox:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
VScrollBar1.Maximum = ListBox1.Items.Count
End Sub
Private Sub VScrollBar1_Scroll(sender As Object, e As ScrollEventArgs) Handles VScrollBar1.Scroll
ListBox1.TopIndex = VScrollBar1.Value
End Sub
-
Archie, nice trick. It is 50% better. The up/dn buttons and the drag bar need to have larger vertical size. Any trick for this?
-
The drag bar can be made larger by increasing the property LargeChange. I don't see anyway to change the arrow button sizes without creating a custom scroll bar.
-
Here is a custom scroll bar that lets you set the ArrowHeight and ThumbHeight. This is basically a framework to start with, it does very little validation so you may want to refine it.
- Download the attached file
- Right click the AdvancedHMI project in Solution Explorer and select Add->Existing Item
- Browse to CustomScrollBar.vb
- Build the project
This is how you would use it:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
CustomScrollBar1.Maximum = ListBox1.Items.Count
End Sub
Private Sub CustomScrollBar1_ValueChanged(sender As Object, e As EventArgs) Handles CustomScrollBar1.ValueChanged
ListBox1.TopIndex = CustomScrollBar1.Value
End Sub
-
I got the arrows to scroll the listview.
I'm unable to find the correct event for the thumb drag. Need some help to implement the thumb drag scroll.
Edit:
It seems the thumb part has to be done from scratch with the mousedown event as this feature is not in the inherited base object "control"
-
You could try the attached control, a combination of Archie's code and code from msdn example:
https://msdn.microsoft.com/en-us/library/system.windows.forms.scrollbarrenderer(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1
It is not perfect but should work (especially for touchscreen devices).
Vertical ScrollBar currently has Maximum value at the bottom (not sure how to go about reversing this, might figure it out in the future).
For Windows Forms only, add HVScrollBar.vb file as ExistingItem to PurchasedControls folder.
AHMI version is here: https://www.advancedhmi.com/forum/index.php?topic=1939.0