Multi-column Scrollview: How to Change Color of Entire Row

Bill Norris

Active Member
Licensed User
Longtime User
My scrollview has 4 columns, all labels. I want to change the color of the entire row when any label in the row is clicked. Ive initialized all of the labels to the same Sub. I have no problem accomplishing this color change with a one-column scrollview, using Sender. Any way to capture the index of the clicked label, then I could change the color of the other labels with that same index. I've read about storing the index in the tag property as the rows are added, but I've got to store other information there.

Thanks,
Bill
 

COBRASoft

Active Member
Licensed User
Longtime User
1 possible way would be by placing the 4 labels in 1 panel. Add the panel as tag object to your labels, so when a label is clicked, you easily know what panel is the 'parent'. From there, you can alter the color of all 'child' views of the panel (your labels).
 
Upvote 0

Bill Norris

Active Member
Licensed User
Longtime User
Not Clear

I think I'm a little to new at this to grasp your explanation. All of the labels are on scrollview.panel. Where do I go from here to utilize your solution?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
What information do you store in the Tag property.
You could define a Type variable with your data plus one value with the index of the Label.
Then, if i is equal to the label index,
B4X:
row = Floor(i / 4)
For n = 0 to 3
  Dim lbl As Label
  lbl = ScrollView1.Panel.Get(row * 4 + i)
  lbl.Color = col  ' color to display
Next
Best regards.
 
Upvote 0

COBRASoft

Active Member
Licensed User
Longtime User
I think I'm a little to new at this to grasp your explanation. All of the labels are on scrollview.panel. Where do I go from here to utilize your solution?

You could place an extra panel for each 'record' and place your labels on that panel.

Tip: if you make the vertical offset of your record-panels 1 higher than your actual panels, you can see the background (scrollview.panel). Very nnice to have a record seperator this way .
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…