I have a graph that I’d like to be able to scroll side to side within a TabPanel.
Is there a scrollable pane I can use? Someone said to use a Canvas, but that doesn’t look to have scrollbars, unless I missed it?
I have a graph that I’d like to be able to scroll side to side within a TabPanel.
Is there a scrollable pane I can use? Someone said to use a Canvas, but that doesn’t look to have scrollbars, unless I missed it?
You have to add the scrollbar to the canvas yourself, as well as control its scrolling yourself.
@Andy Broughton There is no built-in control that would allow you to scroll horizontally/vertically through a Picture, but using a Canvas is the best idea. However, as Tim said, you will need to implement the ScrollBars yourself.
The general idea is that your graph is a Picture and the Canvas displays only a part of it. The X, Y coordinates of the part you display are the horizontal and vertical scrollbars’ value. Rather simple if you don’t want/need to adjust the scale.
Odd that there’s no scrollable pane as a control. The ListBox has that functionality built in.
If I need to implement the scrollbars manually, do I even need a Canvas?
@Andy Broughton [quote]do I even need a Canvas?[/quote]
Well you need any RectControl in which you can draw what you want, and the easiest one is Canvas.
In the ValueChanged event for my vertical scrollbar I have:
[code]Var delta As Integer
delta = ScrollLastY - Me.Value
Canvas1.Scroll (0, delta)
ScrollLastY = Me.Value
[/code]
ScrollLastY is a property on the Window.
Lessee now, what else? Ah, I have a method called checkScrollBar:
[code]Public Sub checkScrollbar()
Var hite As Integer = Canvas1.Height
Var vert As Integer = 1326 // The height of Canvas1 in the IDE (should be a Const, really)
if (hite>vert) then
Scrollbar1.Visible = false
return
end if
Scrollbar1.Visible = true
Scrollbar1.PageStep = hite
Scrollbar1.MaximumValue = vert - Scrollbar1.PageStep
End Sub
[/code]
which gets called in the Open event for the Window containing the canvas, and also the Resizing event.