Scrollview question

Post your Gambas programming questions here.
Post Reply
bill-lancaster
Posts: 195
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Scrollview question

Post by bill-lancaster »

I've only just noticed this.

If I place a control (a button say) in a scrollview container with it's .X value greater than scrollview.W then the horizontal scrollbar is initiated and the control can be brought into view.

However if the .X position of the control is less than scrollview.X then the scrollbar is not initiated.

In other words, a child object to the right of the scrollview can be viewed whereas a child object to the right cannot.

Is this to be expected?
User avatar
BruceSteers
Posts: 1565
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Scrollview question

Post by BruceSteers »

bill-lancaster wrote: Sunday 19th December 2021 11:55am I've only just noticed this.

If I place a control (a button say) in a scrollview container with it's .X value greater than scrollview.W then the horizontal scrollbar is initiated and the control can be brought into view.

However if the .X position of the control is less than scrollview.X then the scrollbar is not initiated.

In other words, a child object to the right of the scrollview can be viewed whereas a child object to the right cannot.

Is this to be expected?
Probably the scrollview.Arrange setting
Arrange.None will give freedom to place objects where you expect them to be and make scrollbars work as expected i should think.

and i don't get this ...
In other words, a child object to the right of the scrollview can be viewed whereas a child object to the right cannot.
If at first you don't succeed , try doing something differently.
BruceS
bill-lancaster
Posts: 195
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: Scrollview question

Post by bill-lancaster »

Thanks Bruce
I thought I'd make it clearer with the last statement, unfortunately it should read:-
In other words, a child object to the right of the scrollview can be viewed whereas a child object to the LEFT cannot.
bill-lancaster
Posts: 195
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: Scrollview question

Post by bill-lancaster »

Tried changing the arrange settings - makes no difference.

Perhaps you might try this:-

Code: Select all

Public Sub Form_Open()
Dim hScrollview As New ScrollView(Me)
  With hScrollview
    .X = 10
    .Y = 10
    .W = 500
    .H = 500
  End With
Dim hFrame As New Frame(hScrollview)
  With hFrame
    .X = -100
    .Y = -10
    .W = 200
    .H = 200
  End With
Dim hFrame2 As New Frame(hScrollview)
  With hFrame2
    .X = 450
    .Y = 50
    .W = 200
    .H = 200
  End With
End
Thanks
Bill
User avatar
BruceSteers
Posts: 1565
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Scrollview question

Post by BruceSteers »

Aah i see.

You cannot use negative numbers.
the box has been placed -100 to the scrollview.X 0 position so it's right.

you should place the frame at 0 and scroll the view +100 to get the same effect.

like this is how i'd do it ..
Public Sub Form_Open()

  Dim hScrollview As New ScrollView(Me)
  With hScrollview
    .Name = "SView"
    .ScrollBar = Scroll.Both
    .Expand = True
    .X = 10
    .Y = 10
    .W = 500
    .H = 500
  End With
  Dim hFrame As New Frame(hScrollview)
  With hFrame
    .X = 0
    .Y = 0
    .W = 200
    .H = 200
  End With
  Dim hFrame2 As New Frame(hScrollview)
  With hFrame2
    .X = 450
    .Y = 50
    .W = 200
    .H = 200
  End With

End

Public Sub Form_Show()

  Dim hScrollview As ScrollView = Me["SView"]
  hScrollview.ScrollX = 100 
  hScrollview.ScrollY = 20

End
If at first you don't succeed , try doing something differently.
BruceS
bill-lancaster
Posts: 195
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: Scrollview question

Post by bill-lancaster »

Thanks Bruce, so negative positions for child objects is not allowed, that explains it.
Thanks again,
Bill
User avatar
BruceSteers
Posts: 1565
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Scrollview question

Post by BruceSteers »

Yeah, the scrollviews left edge 0 is as it is, the left edge. Then the view is scrolled and it's position is negative to the visible window but still 0 to the scrollview object, anything placed negative of that will remain there.
If at first you don't succeed , try doing something differently.
BruceS
Post Reply