how to tell which scrollview was clicked?

dougc

Member
Licensed User
Longtime User
I have searched the forums and the documentation to no avail, I have a view with 3 scroll views on it and I need to react depending on which scroll view was clicked on. I thought if I set teh tag property in the designer I could then use it to tell which scroll view triggered the cell clicked event but sender.tag makes no sense to me

it says tag=[col=0, Initialized=true,row=2] I was expecting the string I set in the designer.

I must be missing/mis understanding something, any help will be greatly appreciated.

to summarize, I have 3 scrollviews in my form and I need to react according to which one of the three scrollviews was clicked on, so what I am struggling to do is figure out which scrollview was clicked on, so I can react accordingly. I thought I could use sender.tag in my cell_click sub

thanks
dougc
 

klaus

Expert
Licensed User
Longtime User
You should either define three Cell_Click routines one for each ScrollView or you could modify the Tag paramter and add an index for the ScrollViews.
The code would be better readable with three Cell_Click routines.

Best regards.
 
Upvote 0

dougc

Member
Licensed User
Longtime User
excellent idea thank you very much, I agree with the 3 cell_click subs as it does make the code easier to understand

dougc
 
Upvote 0

dougc

Member
Licensed User
Longtime User
sorry one more question, when I created ScrollView1_cell_clicked or ScrollView1_cell.click or ScrollView1_cellclicked

none of the above get called, what is the correct name to call the sub so that it gets called when the appropriate scrollview is clicked?

dougc
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
A ScrollView doesn't have a Click event !
The Views in the ScrollView.Panels should have the Event routine names.
When you populate the ScrollView you add views and there you should give the event name when you initialize the views like with a unique ScrollView.
For example in ScrollView1 event name Cell1, Cell2 for ScrollView2 etc.
The you have 3 routines Cell1_Click, Cell2_Click and Cell3_Click.

Best regards.
 
Upvote 0

dougc

Member
Licensed User
Longtime User
thanks after several hours of struggling I finally got it working, I am posting what I did (which now seems simple) for others who may run into a similar issue.......

in my addrows subroutine (which is where I populated the scroll view) here is where I had to initialize the scrollviews with unique names (I kept thinking it was where I initialized the scrollviews) so as I looped through the number of columns I had the following code (whichscrollview is a global variable that tells me which scrollview I am working with)

Dim l As Label
If whichScrollView = 1 Then
l.Initialize("scroll1")
Else
If whichScrollView = 2 Then
l.Initialize("scroll2")
Else
l.Initialize("scroll3")
End If
End If

while it seems obvious now, I spent almost an hour trying to figure out what klaus meant (I was stuck on initializing the scrollview not thinking it was initializing the rows) Now it makes sense to me after much hair pulling, I guess I am still a B4A noob

anyway I hope this helps others who may run across this issue.

thanks Klaus for pointing to the solution, I just couldn't see it for a while

dougc
 
Upvote 0
Top