B4J Question [Workaround] How Sync two ListViews

Discussion in 'B4J Questions' started by Jorge M A, Aug 9, 2019.

  1. Jorge M A

    Jorge M A Active Member Licensed User

    Rookie question.
    I have two ListViews that I need to synchronize when the user clicks on an item, the second list will select the same index. So far I have no problem.
    The problem is the visibility of the selected item. (or the position of the ScrollBar?)
    How can I get both lists to show the item in the same location? (Easy way?)
    Thanks a Lot!
     
  2. Enrique Gonzalez R

    Enrique Gonzalez R Well-Known Member Licensed User

    hi!

    listview has the method ScrollTo.
     
  3. Jorge M A

    Jorge M A Active Member Licensed User

    Yes, thank you, sir. I know that and using it.
    But when I click on an Item, both scroll to the top of the list (FirstVisible Item).
    My question is how to keep the same position in both when clicking, without moving it to the top of the list.
     
  4. Jorge M A

    Jorge M A Active Member Licensed User

    Ok, my basic, solution based on Offset:

    Code:
    Sub CustomListView2_ScrollChanged (Offset As Int)
        CustomListView1.sv.ScrollViewOffsetY=Offset
    End Sub
    Sub CustomListView1_ScrollChanged (Offset As Int)
        CustomListView2.sv.ScrollViewOffsetY=Offset
    End Sub
    Thanks!
     
  5. Brandsum

    Brandsum Active Member Licensed User

    Paste this inside clv 1 item click event
    Code:
    if CustomListView1.sv.ScrollViewOffsetY <> CustomListView2.sv.ScrollViewOffsetY then
            CustomListView2.sv.ScrollViewOffsetY = CustomListView1.sv.ScrollViewOffsetY
    End if
    Paste this inside clv 2 item click event
    Code:
    if CustomListView1.sv.ScrollViewOffsetY <> CustomListView2.sv.ScrollViewOffsetY then
            CustomListView1.sv.ScrollViewOffsetY = CustomListView2.sv.ScrollViewOffsetY
    End if
     
    DonManfred, emexes and Jorge M A like this.
  6. Jorge M A

    Jorge M A Active Member Licensed User

    Thank You Man!
     
    Brandsum and emexes like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice