While implementing ScrollView.ScrollPosition in my application, I ran across something interesting that might be of interest to others.
After listing a few hundred dates on a table within scrCalendar (a ScrollView), I needed to position scrCalendar to a particular date specified by TodayRow. I used the following code within Activity_Create:
However, positioning did NOT happen! But, In trying to debug the code, I happened to add a message box before of the conditional statement:
Now. after clearing the message box, positioning worked (anyone have any explanation as to why?)! I then tried to simulate this same effect without the message box, and got the following to work, implementing a timer:
I have a feeling there's a much easier way to do this, but if not (or if it's a bug), this is a quick workaround.
After listing a few hundred dates on a table within scrCalendar (a ScrollView), I needed to position scrCalendar to a particular date specified by TodayRow. I used the following code within Activity_Create:
For ....
(code that generates table)
Next ....
If TodayRow>=5 Then
(code that generates table)
Next ....
If TodayRow>=5 Then
scrCalendar.ScrollPosition=(TodayRow-5)*RowHeight
ElsescrCalendar.ScrollPosition=0
End IfHowever, positioning did NOT happen! But, In trying to debug the code, I happened to add a message box before of the conditional statement:
For ....
(code that generates table)
Next ....
Msgbox("TodayRow=" & TodayRow,"")
If TodayRow>=5 Then
(code that generates table)
Next ....
Msgbox("TodayRow=" & TodayRow,"")
If TodayRow>=5 Then
scrCalendar.ScrollPosition=(TodayRow-5)*RowHeight
ElsescrCalendar.ScrollPosition=0
End IfNow. after clearing the message box, positioning worked (anyone have any explanation as to why?)! I then tried to simulate this same effect without the message box, and got the following to work, implementing a timer:
For ....
(code that generates table)
Next ....
Tmr.Initialize("ScrDly",10)
Tmr.Enabled=True
...............
Sub ScrDly_tick
End Sub
(code that generates table)
Next ....
Tmr.Initialize("ScrDly",10)
Tmr.Enabled=True
...............
Sub ScrDly_tick
Tmr.Enabled=False
If TodayRow>=5 Then
If TodayRow>=5 Then
scrCalendar.ScrollPosition=(TodayRow-5)*RowHeight
ElsescrCalendar.ScrollPosition=0
End IfEnd Sub
I have a feeling there's a much easier way to do this, but if not (or if it's a bug), this is a quick workaround.